import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 每个月的天数,平年
        int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        // 循环处理多组测试数据
        while (scanner.hasNext()) {
            int year = scanner.nextInt();
            int month = scanner.nextInt();
            int day = scanner.nextInt();

            // 判断是否为闰年
            boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);

            // 计算总天数
            int totalDays = 0;
            // 累加前面月份的天数
            for (int i = 0; i < month - 1; i++) {
                totalDays += daysInMonth[i];
            }
            // 加上当月的天数
            totalDays += day;
            // 如果是闰年且月份大于2月,加1天
            if (isLeapYear && month > 2) {
                totalDays++;
            }

            System.out.println(totalDays);
        }

        scanner.close();
    }
}