// yukicoder: No.79 過小評価ダメ・ゼッタイ // 2019.4.9 bal4u #include #include #define MONTH 7 #define DAY 23 #define WEEK 3 // 水曜 int dayOfWeek(int year, int month, int day) { if (month == 1 || month == 2) { year--; month += 12; } return (year + year / 4 - year / 100 + year / 400 + (13 * month + 8) / 5 + day) % 7; } int calc(int fr, int to) { int f = 0; while (fr <= to) { if (dayOfWeek(fr, MONTH, DAY) == WEEK) f++; fr++; } return f; } int main() { int ans; long long N; scanf("%lld", &N); if (N <= 4000) ans = calc(2015, (int)N); else { N -= 4000; ans = 282 + (int)(N / 2000) * 285; N %= 2000; ans += calc(4000, 4000+(int)N); } printf("%d\n", ans); return 0; }