module main; // https://ja.wikipedia.org/wiki/ツェラーの公式 より // https://tokyoaccent.com/calendar/retro.htm より import std; void main() { // 入力 auto N = readln.chomp.to!long; // 答えの計算と出力 // y年7月23日の曜日(0:日曜日 ~ 6:土曜日) long zeller(long y) { return (y + y / 4 - y / 100 + y / 400 + (13 * 7 + 8) / 5 + 23) % 7; } // 2014年7月23日の曜日 long d0 = zeller(2014); // 2015年を1年目として、1年目から400年目までに7月23日が水曜日になる日が何日あるか auto arr = new long[](401); long d = 0; foreach (y; 1 .. 401) { if (zeller(y + 2014) == d0) d++; arr[y] = d; } long Q = (N - 2015) / 400L; int R = (N - 2015) % 400 + 1; writeln(Q * arr[400] + arr[R]); }