#include<iostream>
#include<string>
using namespace std;

bool isleapYear(int year){
    return (year % 400 == 0) || (year % 4 == 0 && year % 100 !=0);
    
}

int main(){
    string date;
    cin>> date;
    
    if(date.length() !=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(year <1900 || year>2100 || month<1 || month>12){
        cout<<"Invalid input";
        return 0;
    }
    
    int dayInMonth[]={31,28,31,30,31,30,31,31,30,30,31};
    if(isleapYear(year)){
        daysinMonth[1] = 29;
    }
    
    if(day < 1 || day >daysInMonth[month - 1]){
        cout<<"Invalid input";
        return 0;
    }
    
    int dayNumber = 0;
    for(int i=0; i<month - 1; i++){
        dayNumber += daysInMonth[i];
        
    }
    dayNumber += day;
    
    cout<< dayNumber;
    return 0;
}