//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define no_of_digits(n) floor(log10(n)) + 1
#define bits(n) __builtin_popcount(n)

void solve()
{
    char s;
    cin>>s;
    char t;
    cin>>t;
    if(s=='Y')
    {
        cout<<(char)toupper(t);
    }
    else
    cout<<(char)tolower(t);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

string s;

char get (char c) {
  if (c == '0') return '0';
  if (c == '1') return '1';
  if (c == '6') return '9';
  if (c == '9') return '6';
  if (c == '8') return '8';
  return 0;
}

int main() {
  cin >> s;
  reverse(s.begin(), s.end());
  for (char &c : s) c = get(c);
  cout << s << '\n';
  return 0;
}

