#include
main()
{
int n,y,r,k=0,a,b,h=0;
scanf("%d%d%d",&n,&y,&r);
if(n%100!=0&&n%4==0||n%400==0)
{
switch(y)
{
case 12:k=k+30;
case 11:k=k+31;
case 10:k=k+30;
case 9:k=k+31;
case 8:k=k+31;
case 7:k=k+30;
case 6:k=k+31;
case 5:k=k+30;
case 4:k=k+31;
case 3:k=k+29;
case 2:k=k+31;
}
}
else
{
switch(y)
{
case 12:k=k+30;
case 11:k=k+31;
case 10:k=k+30;
case 9:k=k+31;
case 8:k=k+31;
case 7:k=k+30;
case 6:k=k+31;
case 5:k=k+30;
case 4:k=k+31;
case 3:k=k+29;
case 2:k=k+31;
}
}
a=k+r;
for(b=1900;b {
if(b%100!=0&&b%4==0||b%400==0)
h=h+366;
else
h=h+365;
}
if((a+h-1)%7==0)
printf("0");
else
printf("%d",(a+h-1)%7);
}