// editor2
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
int main()
{
    int day, month, year;
    string op;
    int n;
    cin >> day >> month >> year;
    cin >> op >> n;
    if (month < 1 || month > 12 || day < 1 || day > 31)
    
    {
        cout << "Invalid input";
        return 0;
    }
    tm date = { };
    date = tm_mday = day;
    date = tm_mon = month - 1;
    date = tm_year = year - 1900;
    time_t time_val = mktime(&date);
    if(time_val == -1)
    {
        cout << "Invalid input";
        return 0;
    }
    if (op == "add")
    {
        time_val += n * 24 * 60 * 60;
    }
    else if(op == "subtract")
    {
        time_val == n * 24 * 60 * 60;
    }
    else 
    {
        cout << "Invalid input";
        return 0;
    }
    tm * new_date = localtime(&time_val);
    cout << setfill('0') << setw(2) << new_date -> tm_mday << "/"
    << setfill('0') << setw(2) << new_date -> tm_mon + 1 "/" << new_date -> tm_year = 1900;
    return 0;
}