/*#include <stdio.h>
int main()
{
int array[3],i,sum;
for(i=0;i<3;i++)
{
scanf("%d",&array[i]);
}
sum=array[0]+array[1]+array[2];
if((sum/100)%2==0)
{
printf("대박");
}
else{printf("그럭저럭");}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int a;
scanf("%d",&a);
if( a%10==1 && a!=11 )
{
printf("%dst",a);
}
else if(a%10==2&& a!=12 )
{
printf("%dnd",a);
}
else if(a%10==3&&a !=13)
{
printf("%drd",a);
}
else
{
printf("%dth",a);
}
return 0;
}
*/
/*#include <stdio.h>
int main()
{
float a,b,c,d;
scanf("%f %f %f %f",&a,&b,&c,&d);
if(a/b>c/d)
{
printf(">");
}
else if(a/b<c/d)
{
printf("<");
}
else
{
printf("=");
}
return 0;
}*/
/*#include <stdio.h>
int main()
{
long long int a;
scanf("%lld",&a);
printf("%lld",++a);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[21],str2[21],str3[21];
scanf("%s %s %s",str1,str2,str3);
if( str1[strlen(str1)-1]==str2[0]
&&str2[strlen(str2)-1]==str3[0]
&&str1[0]==str3[strlen(str3)-1])
{
printf("good");
}
else
{
printf("bad");
}
}
*/
/*#include <stdio.h>
int a[10001];
int n, i, j, temp;
int main() {
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d", &a[i]);
for(i=1; i<n; i++)
{
// 이 부분에 들어가야 될 코드를 작성하여 제출
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for (i = 1; i <= n; i++)
printf("%d\n", a[i]);
return 0;
}
/*
5
3 1 2 5 4
=> 오름차순
1 2 3 4 5
1. 버블정렬
4 1 3 2 5
1 4 3 2 5
1 3 4 2 5
1 3 2 4 5
1 3 2 4 : 5
1 3 2 4 : 5
1 2 3 : 4 5
1 2 : 3 4 5
1 : 2 3 4 5
//bubble sort
#include <stdio.h>
int a[10001];
int n, i, j, temp;
int main() {
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d", &a[i]);
for(i=1; i<n; i++)
{
for(j=1;j<=n-i;j++)
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for (i = 1; i <= n; i++)
printf("%d\n", a[i]);
return 0;
}
5 3 1 2 4
n=5
i=1
3 5 1 2 4
3 1 5 2 4
3 1 2 5 4
3 1 2 4 5 j=4
i=2
3 1 2 4 j=1
1 3 2 4 j=2
1 2 3 4 j=3
1 2 3 4
i=3
1 2 3 j=1
1 2 3 j=2
i=4
1 2 j=1
*/
#include <stdio.h>
#include <string.h>
int main()
{
char str[500];
int sum=0,i,len;
scanf("%s",str);
len=strlen(str);
for(i=0;i<len;i++)
{
sum=sum+str[i]-48;
}
printf("%d",sum%3==0);
return 0;
}