program gr;
var
a,s,d,f,g,z,x,c:integer;
begin
readln(a,s,d);
g:=1;
c:=s;
f:=1900;
while a<>1900 do
begin
case s of
1,3,5,7,8,10,12:z:=+31;
4,6,9,11:z:=30;
2:if (f mod 400=0) or (f mod 100<>0) and(f mod 4=0)then z:=29 else z:=28;
end;
for x:=1 to z do
begin
g:=g mod 7+1;
if (f=a) and (s=c) ang (d=x) then exit;
end;
writeln(g);
end.