import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
String str = sc.nextLine();
String[] split = str.split(" ");
int year = Integer.parseInt(split[0]);
int month = Integer.parseInt(split[1]);
int day = Integer.parseInt(split[2]);
int sum = 0;// 共多少天
// int[] months = {31,29,31,30,31,30,31,31,30,31,30,31};
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
// 闰年,2月为29天
int[] months = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 0; i < month - 1; i++) {
sum += months[i];
}
sum += day;
} else {
// 平年,2月为28天
int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 0; i < month - 1; i++) {
sum += months[i];
}
sum += day;
}
System.out.println(sum);
}
}
}