n = gets.to_i ans = (n - 2014) / 400 * 57 n = (n - 2014) % 400 + 2014 d = 0 2015.upto(n){|y| if y % 400 == 0 d += 2 else if y % 100 == 0 d += 1 else if y % 4 == 0 d += 2 else d += 1 end end end if d % 7 == 0 ans += 1 end } p ans