#include using namespace std; inline bool isLeapYear(int year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); } inline int countLeapYear(int year) { return year / 4 - year / 100 + year / 400; } inline int getMaxDay(int year, int month) { const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (month == 2) return isLeapYear(year) ? 29 : 28; return days[month]; } struct Day { int year, month, day; enum {SUN, MON, TUE, WED, THU, FRI, SAT}; Day() : year(0), month(0), day(0) {} Day(int year, int month, int day) : year(year), month(month), day(day) {} int fairfield() const { int y = year, m = month; if (m <= 2) --y, m += 12; return 365 * y + countLeapYear(y) + (153 * (m + 1) / 5) + day - 428; } int operator-(const Day& day) const { return fairfield() - day.fairfield(); } bool operator<(const Day& day) const { if (year != day.year) return year < day.year; if (month != day.month) return month < day.month; return this->day < day.day; } Day operator++() { ++day; if (getMaxDay(year, month) < day) { ++month; day = 1; if (month == 13) { ++year; month = 1; } } return *this; } int weekday() { return fairfield() % 7; } }; int solve(long long n) { Day day(0, 7, 23); int res = 0; for (int i = 0; i < 400; ++i) { day.year = i; if (day.weekday() == Day::WED) ++res; } res *= n / 400; for (int i = 0; i <= n % 400; ++i) { day.year = i; if (day.weekday() == Day::WED) ++res; } return res; } int main() { long long n; cin >> n; cout << solve(n) - solve(2014) << endl; }