import std.stdio;void main(){for(int y,m,d;~scanf("%d%d%d",&y,&m,&d);writeln((y+y/4-y/100+y/400+m*13/5+d)%7))m+=m<3?y--,18:6;}