#include <iostream>
#include <string>
#include <stdio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
bool isrn(int n){
if(n%4==0&&n%100!=0||n%400==0){
return true;
}else{
return false;
}
}
int main(int argc, char** argv) {
int date;
cin>>date;
int year = 1777;
int month = 4;
int day = 30;
int rnmonth[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
int pnmonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int months[13];
if(isrn(year)){
memcpy(months,rnmonth,sizeof(rnmonth));
}else{
memcpy(months,pnmonth,sizeof(pnmonth));
}
while(--date){
if(day+1>months[month]){
month+=1;
day=1;
if(month>12){
year+=1;
month=1;
if(isrn(year)){
memcpy(months,rnmonth,sizeof(rnmonth));
}else{
memcpy(months,pnmonth,sizeof(pnmonth));
}
}
}else{
day=day+1;
}
}
// cout<<year<<"-"<<month<<"-"<<day;
printf("%4d-%02d-%02d",year,month,day);
return 0;
}