import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()){
int year=sc.nextInt();
int month=sc.nextInt();
int day=sc.nextInt();
int x=0,y=0,i;
int count=0;
for( i=1;i<month;i++) {
switch(i){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
x++;
break;
case 4:
case 6:
case 9:
case 11:
y++;
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
count=29;
} else {count=28;}
}
}
count=count+31*x+30*y+day;
System.out.println(count);
}
}
}