import java.util.Scanner; public class Main { public static long simulate_count(final long begin, final long end, final int init_days, final int correct){ int days = init_days; long count = 0; for(long year = begin; year < end; year++){ if(year % 400 == 0){ days += 2; }else if(year % 100 == 0){ days += 1; }else if(year % 4 == 0){ days += 2; }else{ days += 1; } days %= 7; if(days == correct){ count++; } } return count; } public static long simulate_days(final long begin, final long end, final int init_days, final int correct){ int days = init_days; long count = 0; for(long year = begin; year < end; year++){ if(year % 400 == 0){ days += 2; }else if(year % 100 == 0){ days += 1; }else if(year % 4 == 0){ days += 2; }else{ days += 1; } days %= 7; if(days == correct){ count++; } } return days; } // [year) public static void simulation(final int initial_days, final int correct_days, final long year, int[] nexts, long[] counts){ int days = initial_days; long count = 0; for(long i = 0; i < year; i++){ if(i % 400 == 0){ days += 2; }else if(i % 100 == 0){ days += 1; }else if(i % 4 == 0){ days += 2; }else{ days += 1; } days %= 7; if(days == correct_days){ count++; } } nexts[initial_days] = days; counts[initial_days] = count; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final long N = sc.nextLong(); final int correct_days = 3; int days = 3; long[] counts_1 = new long[7]; long[] counts_4 = new long[7]; long[] counts_100 = new long[7]; long[] counts_400 = new long[7]; int[] nexts_1 = new int[7]; int[] nexts_4 = new int[7]; int[] nexts_100 = new int[7]; int[] nexts_400 = new int[7]; for(int d = 0; d < 7; d++){ simulation(d, correct_days, 1, nexts_1, counts_1); simulation(d, correct_days, 4, nexts_4, counts_4); simulation(d, correct_days, 100, nexts_100, counts_100); simulation(d, correct_days, 400, nexts_400, counts_400); } long answer = 0; for(long year = 2015; year <= N; ){ //System.out.println(year + " " + answer); if(year % 400 == 0 && ((year + 400) <= N)){ answer += counts_400[days]; days = nexts_400[days]; year += 400; }else if(year % 100 == 0 && ((year + 100)) <= N){ answer += counts_100[days]; days = nexts_100[days]; year += 100; }else if(year % 4 == 0 && ((year + 4) <= N)){ answer += counts_4[days]; days = nexts_4[days]; year += 4; }else{ answer += counts_1[days]; days = nexts_1[days]; year += 1; } } System.out.println(answer); } }