#include <iostream>
#include <cmath>
#include <chrono>
#include <iomanip>

typedef std::chrono::high_resolution_clock Clock;

int main()
{
    //auto t1 = Clock::now();
    std::string inp;
    std::cin >> inp;
    int day,month, year = 1980;
    day = month = 0;
    if (inp.size() == 16)
    {
        for (int i = 6; i > 0; --i)
            if (inp[i] == '1')
                year += pow(2, 6 - i);
        for (int i = 10; i > 6; --i)
            if (inp[i] == '1')
                month += pow(2, 10 - i);
        for (int i = 15; i > 10; --i)
            if (inp[i] == '1')
                day += pow(2, 15 - i);
        if (day == 0 || month == 0)
            std::cout << "ERROR" << std::endl;
        else
        {
            std::cout << year << "-";
            std::cout.fill('0');
            std::cout << std::setw(2) << month << "-" << std::setw(2) << day << std::endl;
        }
    }
    if (inp.size() == 10)
    {
        char out[17] = "0000000000000000";
        std::string tyear = "";
        copy(inp.begin(), inp.begin() + 4, tyear.begin());
        std::string tmonth = "";
        copy(inp.begin() + 5, inp.begin() + 7, tmonth.begin());
        std::string tday = "";
        copy(inp.begin() + 8, inp.end(), tday.begin());
        year = atoi(tyear.c_str()) - 1980;
        month = atoi(tmonth.c_str());
        day = atoi(tday.c_str());
        int i;
        for (i = 6; i >= 0 && year / 2; --i)
        {
            if (year % 2)
                out[i] = '1';
            else
                out[i] = '0';
            year /= 2;
        }
        out[i] = '1';
        for (i = 10; i > 6 && month / 2; --i)
        {
            if (month % 2)
                out[i] = '1';
            else
                out[i] = '0';
            month /= 2;
        }
        out[i] = '1';
        for (i = 15; i > 10; --i)
        {
            if (day % 2)
                out[i] = '1';
            else
                out[i] = '0';
            day /= 2;
        }
        out[i] = '1';
        out[16] = '\0';
        std::cout << out << std::endl;

    }

    //auto t2 = Clock::now();
    //std::cout << "Delta t2-t1: "
              //<< std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count()
              //<< " nanoseconds" << std::endl;

    return 0;
}
