import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();
        int month = in.nextInt();
        int day = in.nextInt();

        int[] monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        // 闰年计算规则
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            monthDays[1] = 29;
        }
        int days = 0;
        // 加上该月之前月份的天数
        for (int i = 0; i < month - 1; i++) {
            days += monthDays[i];
        }
        // 加上该月的天数
        days += day;

        System.out.println(days);
    }
}