import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
String[] a = in.nextLine().split(" ");
int[] mlist = new int[] {31, 0, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31
};
int y = Integer.valueOf(a[0]);
if ((y % 4 == 0 && y % 100 != 0 ) || (y % 400 == 0 )) {
mlist[1] = 29;
} else {
mlist[1] = 28;
}
int sum = Integer.valueOf(a[2]);
for (int i = 0; i < Integer.valueOf(a[1]) - 1; i++) {
sum += mlist[i];
}
System.out.println(sum);
}
}
}