n=gets.to_i-2015 memo=Array.new(400,0) diff=0 400.times{|dy| y=dy+2015 diff+=(((y%4==0 && y%100!=0) || y%400==0) ? 2 : 1) memo[dy]=diff%7==0 ? 1 : 0 } ans=memo.inject(:+)*(n/400) p ans+memo[0..(n%400)].inject(:+)