require 'date' N = gets.to_i Y = 2015 ans = (Y..[N, Y + 400].min).map {|y| if Date.new(y, 7, 23).wednesday? 1 + (N - y) / 400 else 0 end }.inject(:+) puts ans