P = [0] * 400 P[0] = 1 Year = 2002 for i in range(1,400): if Year % 400 == 0: P[i] = P[i-1] + 2 elif Year % 100 == 0: P[i] = P[i-1] + 1 elif Year % 4 == 0: P[i] = P[i-1] + 2 else: P[i] = P[i-1] + 1 P[i] %= 7 Year += 1 N = int(input()) M = 2014 Div1 = N // 400 Rem1 = N % 400 Div2 = M // 400 Rem2 = M % 400 print((Div1 * P.count(3) + P[:Rem1].count(3)) - (Div2 * P.count(3) + P[:Rem2].count(3)))