#include
#include<math.h>
using namespace std;
void Boston(long long n)
{
int temp =0;
int x = n;
while(n%2 == 0)
{
temp = temp+2;
n = n/2;
}
for(int i=3;i<=sqrt(n);i=i+2)
{
while(n%i == 0)
{
temp = temp+i;
n=n/i;
}
}
if(n>2)
{
temp = temp+n;
}
int val =0;
int i;
while(x>0)
{
i=x%10;
val = i+val;
x = x/10;
}
if(temp == val )
{
cout<<1<<endl;
}
else
{
cout<<0<<endl;
}
}
int main()
{
long long n;
cin>>n;
Boston(n);
return 0;
}