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

#define ll long long
#define forn_1(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)


void solve()
{
	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string str;
	cin>>str;
	int n=str.size();
   reverse(str.begin(),str.end());
	forn_1(i,0,n) {if(str[i]=='9') cout<<'6';
	else if(str[i]=='6') cout<<'9';
	else cout<<str[i];
}

	return 0;
}
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
#define rep(i, x) for (int i = 0; i < x; i++)
// const int INF = 998244353;
const int MOD = 998244353;

int main() {
    int n;
    cin >> n;
    cout << n-1;
}