import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
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={0,31,28,31,30,31,30,31,31,30,31,30,31};
        if((year%4==0&&year%100!=0)||(year%400==0)){
            arr[2]++;
        }
        int sum=0;
        for (int i = 1; i < month; i++) {
            sum+=arr[i];
        }
        sum+=day;
        System.out.println(sum);
    }
}