import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static int[][] mon={{1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31}};
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       while(sc.hasNextLine()){
        String line = sc.nextLine();
        String[] str = line.split(" ");
        int year = Integer.valueOf(str[0]);
        int month = Integer.valueOf(str[1]);
        int day = Integer.valueOf(str[2]);
        int res = 0;
        if(isLeap(year)){ //闰年
            mon[1][1] = 29;
           
        }
         for(int i=0;i<month-1;i++){
                res+=mon[i][1];
            }
            res+=day;
             System.out.println(res);
       }
      
    }
    public static boolean isLeap(int year){
        return (year%4==0 && year%100!=0) || (year%400==0);
    }
}