import java.util.*;
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 count = 0;
switch(month){
case 12:
count += 30;
case 11:
count += 31;
case 10:
count += 30;
case 9:
count += 31;
case 8:
count += 31;
case 7:
count += 30;
case 6:
count += 31;
case 5:
count += 30;
case 4:
count += 31;
case 3:
if((year%4 == 0 &&year %100 != 0)||year % 400 == 0){
count+=29;
}
else
count += 28;
case 2:
count += 31;
case 1:
count += day;
}
System.out.println(count);
}
}