/**So..a**/
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define __lcm(a, b) (a/__gcd(a, b)*b)

#define PI acos(-1)
#define EXP 10e-6
#define what_is(x) cerr << #x << " is " << x << endl;

template<typename item>
item abs(item i)
{
    if(i < 0) i= -i;
    return i;
}
ll mod = 1000000000+7;
template<class typea>
typea POW(typea b, typea p)
{
    typea res = 1;
    while(p)
    {
        if(p&1)
        {
            res*=b;
            res%=mod;
        }
        b*=b;
        b%=mod;


        p/=2;
    }
    return res;
}

int  tc =0;
#define ull unsigned long long int

#define maxn 2*100000+10
ll arr[maxn];
char a[maxn], b[maxn];
ll n, m, ans;
int main()
{
   string s;
   cin >> s;
   reverse(all(s));
   for(auto &x: s) if(x=='9') x = '6'; else if(x=='6') x = '9';
   cout <<s;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define PI 3.1415926535
#define maxn 100005
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void _SSGJ_()
{   
	string s;
	cin>>s;

	int n= s.length();
	int cnt[26]={0};

	int ans=0;
	for(int i=n - 1,j=0;i > 0;i--,j++)
	{
		if(i < n - 1 && i && s[i] == s[i - 1] && s[i] != s[i + 1])
		{
			ans+=j - cnt[s[i] - 'a'];

			for(int it=0;it<26;it++)
				cnt[it]=0;

			cnt[s[i] - 'a']=j;
		}

		cnt[s[i] - 'a']++;
	}

	cout<<ans<<"\n";
}

signed main()
{

    speedUp

    #ifndef ONLINE_JUDGE   
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);   
    #endif 

   /* int t;
    cin>>t;
    while(t--)*/
    _SSGJ_();
    return 0;

}