import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static boolean leap_year(int year) {
        if ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0)) {
            return true;
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();
        int month = in.nextInt();
        int date = in.nextInt();
        int sum = 0;
        int[] arr1 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
        int[] arr2 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
        if (leap_year(year)) {
            for (int i = 0; i < month - 1; i++) {
                sum += arr1[i];
            }
        } else {
            for (int i = 0; i < month - 1; i++) {
                sum += arr2[i];
            }
        }
        System.out.println(sum + date);
    }
}