import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); // int[] days_month = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int[] days_month = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};

    //         int[] total = new int[12];

// for(int i = 1;i < 13;i++){ // days_month[i] += days_month[i - 1]; // } String[] str1 = str.split(" "); int year = Integer.parseInt(str1[0]); int month = Integer.parseInt(str1[1]); int day = Integer.parseInt(str1[2]); int flag = 0; if(year % 4 == 0 ){ flag = 1; if(year % 100 == 0){ if(year % 400 == 0); else flag = 0; } } if(month > 2){ System.out.println(days_month[month -1] + day + flag); }else{ System.out.println(days_month[month -1] + day); }

}

} // import java.io.BufferedReader; // import java.io.IOException; // import java.io.InputStreamReader;

// public class Main { // public static void main(String[] args) throws IOException { // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // String str; // while ((str = br.readLine()) != null) { // String[] data = str.split(" "); // int year = Integer.parseInt(data[0]); // int mouth = Integer.parseInt(data[1]); // int day = Integer.parseInt(data[2]);

// int[] arr = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};

// if(year % 100 == 0 && year % 400 ==0 && mouth > 2) { // System.out.println(arr[mouth - 1] + day + 1); // } else if (year % 100 != 0 && year % 4==0) { // System.out.println(arr[mouth - 1] + day + 1); // } else { // System.out.println(arr[mouth - 1] + day); // }

// } // } // }