def fairfield(y, m, d): if m <= 2: y -= 1 m += 12 return 365 * y + y / 4 - y / 100 + y / 400 + 306 * (m + 1) / 10 + d - 428 def zeller(y, m, d): return fairfield(y, m, d) % 7 N = input() num = 0 total = [0] * 2800 y, m, d = 2014, 7, 23 for i in xrange(2800): if zeller(y + i, m, d) == 3: num += 1 total[i] = num q = (N - y) / 2800 ans = total[N - y - 2800 * q] + total[2800 - 1] * q - 1 print ans