#include <stdio.h>

typedef struct {
    int year;
    int month;
    int day;
} Date;

int main() {
    Date date;
    scanf("%d %d %d", &date.year, &date.month, &date.day);

    int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if ((date.year % 4 == 0 && date.year % 100 != 0) || date.year % 400 == 0) {
        days_in_month[2] = 29;
    }

    int days = 0;
    int i;
    for ( i = 1; i < date.month; i++) {
        days += days_in_month[i];
    }
    days += date.day;

    printf("%d", days);
    return 0;
}
