#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{ int i=0,n,p=0;
scanf("%d",&n);
for(i=100;i<=n;i++)
{ int temp=i;
int sum=0;
int count=0;
while(temp)
{ count++;
temp/=10;}
temp=i;
while(temp)
{ sum+=pow((temp%10)/1.0,count);
temp/=10;}
if(sum==i)
{p=p+1;
printf("%5d%5d",sum,p);
}
}
system("pause");
return 0;
}