/*
1600年一月一日为星期6,所以算出ymd与1600-1-1差多少天对7取余即可
*/
#include<stdio.h>
int a[]={};
int main()
{
int i,y,m,d,t = ,ans;
for(i=; i<; i+=)
{
if(i% != || i%==)
++t;
a[i-] = a[i-] = a[i-] = a[i-] = t;
}
while(~scanf("%d%d%d",&y,&m,&d))
{
ans = + (y-)* + a[y-];
switch(m)
{
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
case :d+=;break;
}
if( (m> && y%== && y%!=) || y%== && m>)
d++;
ans += d;
printf("%d\n",ans%);
}
return ;
}
//最优解
#include<cstdio>
int main()
{
int y,m,d;
while(~scanf("%d%d%d",&y,&m,&d))
{
if(m<) m+=,--y;
printf("%d\n",(d+*m+*(m+)/+y+y/-y/+y/+)%); //蔡勒公式的变种
}
}