#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	long long k;
	cin >> k;
	while (k % 10 == 0) { k /= 10; }
	while (k > 0) {
		int l = k % 10;
		if (l == 2) { l = 5; }
		else if (l == 5) { l = 2; }
		cout << l;
		k /= 10;
	}
}