d=6 c=(0..399).map{|i|d+=(i%4>0||i%100<1?1:2);d%=7} n=gets.to_i-2000 p n/400*57+c[0..n%400].count(3)-3