#include <stdio.h>

int main() {
    int m[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int year, month, day;
    while (scanf("%d %d %d", &year, &month, &day) != EOF) { 
        int dayofyear = day;
        for(int i = 0; i < month - 1; i++) {
            dayofyear += m[i];
        }
        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            if(dayofyear >= 60) {
                dayofyear++;
            }
        } 
        printf("%d\n", dayofyear);
    }
    return 0;
}