#include<iostream>
#include<string>

bool isleapYear(int year) {
    if ((year % 4 == 0 && year % 100 !=0 ) || (year % 400 == 0 ))\
       return true;
       return false;
}
int main() {
    string date;
    cin >> date;
    
    if (date.lenth() != 10 || date[4] != '-' || date[7] != '-') {
        cout << " Invalid input";
        return 0;
    }
    int year, month, day;
    try {
        year = stoi(date.substr(0, 4));
        month = stoi(date.substr(5, 2));
        day = stoi(date.substr(8, 2));
        
} catch (...) {
   cout<<"Invalid input";
   return 0;
}
if( cout << 1900 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31 ) {
    cout<<"Invalid input";
    return 0;
}
int daysInMonth[] = {31, 28, 31, 30, 31, 30,
                     31, 31, 30, 31, 30, 31};
    if (isLeapyear(year)) {
        daysInMonth[1] = 29;
    }
    if (day>daysInMonth[month -1]) {
        cout<<"Invalid input";
        return 0;
    }
    int dayOfYear = 0;
    for (int i = 0; i < month -1; i++) {
        dayOfYear += daysInMonth[i];
    }
    dayOfYear += day;
    cout<< dayOfYear;
    return 0;
}