#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  string s;
  cin >> s;
  reverse(all(s));
  int n = stoll(s);
  s = to_string(n);
  for (auto i : s) {
    if (i == '5') i = '2';
    else if (i == '2') i = '5';
  }
  cout << s;
}
