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



int main()
{
    int t;
    t=1;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=s.size()-1;i>=0;i--)
        {
            if(s[i]=='9')
                cout<<6;
            else if(s[i]=='6')
                cout<<9;
            else
                cout<<s[i];
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()
#define fr first
#define sc second
#define nl '\n'




void solve(){

    ll n;cin>>n;
    ll ans=0;
    ll a[5]={999,999999,999999999,999999999999,999999999999999};
    int i=0;
    while(n-a[i]>0 && i<5){
        ans+=n-a[i];
        i++;
    }
    cout<<ans;




}

int main(){

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


    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }


return 0;
}
