import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int year=sc.nextInt();
int month=sc.nextInt();
int day=sc.nextInt();
int[] arr=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
int days=0;
for(int i=0;i<month-1;i++){
days+=arr[i];
}
if(isRun(year) && month>2){
days+=1;
}
days+=day;
System.out.println(days);
}
public static boolean isRun(int year){
return year%400==0 || (year%4==0 && year%100!=0);
}
}