#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
ll a[maxx],ch[200],sum[200];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    ll t,n,x,ans=0;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        a[s[i]]++;
    ans=*max_element(a+97,a+122);
    for(int i=97;i<=122;i++)
    {
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=len;j>=0;j--)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            else ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum+97,sum+122));
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=0;j<len;j++)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            else ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum+97,sum+122));
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[maxx];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    int t,n,x;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
    {
        a[s[i]]++;
    }
    int maxo=0,maxt=0;
    for(int i=97;i<=122;i++)
    {
        if(a[i]>=maxo) maxt=maxo,maxo=a[i];
        else if(a[i]>=maxt) maxt=a[i];
    }
    if(!maxt) cout<<maxo<<endl;
    else cout<<maxt*maxo<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
ll a[maxx],ch[200],sum[200];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    ll t,n,x,ans=0;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        a[s[i]]++;
    ans=*max_element(a+97,a+122);
    for(int i=97;i<=122;i++)
    {
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=len;j>=0;j--)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            else ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum+97,sum+122));
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
ll a[maxx],ch[200],sum[200];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    ll t,n,x,ans=0;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        a[s[i]]++;
    ans=*max_element(a+97,a+122);
    for(int i=97;i<=122;i++)
    {
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=len-1;j>=0;j--)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum+97,sum+122));
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
ll a[maxx],ch[200],sum[200];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    ll t,n,x,ans=0;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        a[s[i]]++;
    ans=*max_element(a,a+150);
    for(int i=97;i<=122;i++)
    {
        if(!a[i]) continue;
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=len-1;j>=0;j--)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum,sum+150));
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[maxx],ch[200],sum[200];
char s[maxx];
int main()
{
    ios::sync_with_stdio(0);
    int t,n,x,ans=0;
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        a[s[i]]++;
    ans=*max_element(a+97,a+122);
    for(int i=97;i<=122;i++)
    {
        memset(sum,0,sizeof sum);
        memset(ch,0,sizeof ch);
        for(int j=len;j>=0;j--)
        {
            if(s[j]==i)
            {
                for(int k=97;k<=122;k++)
                {
                    sum[k]+=ch[k];
                }
            }
            else ch[s[j]]++;
        }
        ans=max(ans,*max_element(sum+97,sum+122));
    }
    cout<<ans<<endl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            vector<int> tp1 = it->second, tp2 = itt->second;
            int cnt = 0;
            for(int i = 0; i < tp1.size(); i++)
            {
                if(lb == tp2.end()) break;
                auto lb = upper_bound(all(tp2), tp1[i]);
                cnt += (tp2.end() - lb);
            }
            mx = max(mx, cnt);
            cnt = 0;
            for(int i = 0; i < tp2.size(); i++)
            {
                if(lb == tp1.end()) break;
                auto lb = upper_bound(all(tp1), tp2[i]);
                cnt += (tp1.end() - lb);
            }
            mx = max(mx, cnt);
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            vector<int> tp1 = it->second, tp2 = itt->second;
            int cnt = 0;
            for(int i = 0; i < tp1.size(); i++)
            {
                auto lb = upper_bound(all(tp2), tp1[i]);
                if(lb == tp2.end()) break;
                cnt += (tp2.end() - lb);
            }
            mx = max(mx, cnt);
            cnt = 0;
            for(int i = 0; i < tp2.size(); i++)
            {
                auto lb = upper_bound(all(tp1), tp2[i]);
                if(lb == tp1.end()) break;
                cnt += (tp1.end() - lb);
            }
            mx = max(mx, cnt);
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, (nn*(nn-1))/2);
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                vector<int> tp1 = it->second, tp2 = itt->second;
                int cnt = 0;
                for(int i = 0; i < tp1.size(); i++)
                {
                    auto lb = lower_bound(all(tp2), tp1[i]);
                    cnt += (tp2.end() - lb);
                    if(lb == tp2.end()) break;
                }
                mx = max(mx, cnt);
                cnt = 0;
                for(int i = 0; i < tp2.size(); i++)
                {
                    auto lb = lower_bound(all(tp1), tp2[i]);
                    cnt += (tp1.end() - lb);
                    if(lb == tp1.end()) break;
                }
                mx = max(mx, cnt);
            }
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        mx = max(mx, (int)((it->second).size()));
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                vector<int> tp1 = it->second, tp2 = itt->second;
                int cnt = 0;
                for(int i = 0; i < tp1.size(); i++)
                {
                    auto lb = lower_bound(all(tp2), tp1[i]);
                    cnt += (tp2.end() - lb);
                    if(lb == tp2.end()) break;
                }
                mx = max(mx, cnt);
                cnt = 0;
                for(int i = 0; i < tp2.size(); i++)
                {
                    auto lb = lower_bound(all(tp1), tp2[i]);
                    cnt += (tp1.end() - lb);
                    if(lb == tp1.end()) break;
                }
                mx = max(mx, cnt);
            }
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, (nn*(nn-1))/2);
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                vector<int> tp1 = it->second, tp2 = itt->second;
                int cnt = 0;
                for(int i = 0; i < tp1.size(); i++)
                {
                    auto lb = lower_bound(all(tp2), tp1[i]);
                    cnt += (tp2.end() - lb);
                    //if(lb == tp2.end()) break;
                }
                mx = max(mx, cnt);
                cnt = 0;
                for(int i = 0; i < tp2.size(); i++)
                {
                    auto lb = lower_bound(all(tp1), tp2[i]);
                    cnt += (tp1.end() - lb);
                    //if(lb == tp1.end()) break;
                }
                mx = max(mx, cnt);
            }
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, (nn*(nn-1))/2);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                vector<int> tp1 = it->second, tp2 = itt->second;
                int cnt = 0;
                for(int i = 0; i < tp1.size(); i++)
                {
                    auto lb = lower_bound(all(tp2), tp1[i]);
                    cnt += (tp2.end() - lb);
                    if(lb == tp2.end()) break;
                }
                mx = max(mx, cnt);
                cnt = 0;
                for(int i = 0; i < tp2.size(); i++)
                {
                    auto lb = lower_bound(all(tp1), tp2[i]);
                    cnt += (tp1.end() - lb);
                    if(lb == tp1.end()) break;
                }
                mx = max(mx, cnt);
            }
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,int> fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]] ++;
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        mx = max(mx, it->second);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                mx = max(mx, it->second * itt->second);
            }
        }
    }
    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size())-1;
        mx = max(mx, (nn*(nn+1))/2);
        mx = max(mx, nn+1);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            if(it != itt)
            {
                vector<int> tp1 = it->second, tp2 = itt->second;
                int cnt = 0;
                for(int i = 0; i < tp1.size(); i++)
                {
                    auto lb = lower_bound(all(tp2), tp1[i]);
                    cnt += (tp2.end() - lb);
                    if(lb == tp2.end()) break;
                }
                mx = max(mx, cnt);
                cnt = 0;
                for(int i = 0; i < tp2.size(); i++)
                {
                    auto lb = lower_bound(all(tp1), tp2[i]);
                    cnt += (tp1.end() - lb);
                    if(lb == tp1.end()) break;
                }
                mx = max(mx, cnt);
            }
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    ll mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        ll nn = (ll)((it->second).size());
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            vector<int> tp1 = it->second, tp2 = itt->second;
            ll cnt = 0;
            for(int i = 0; i < tp1.size(); i++)
            {
                auto lb = upper_bound(all(tp2), tp1[i]);
                if(lb == tp2.end()) break;
                cnt += (tp2.end() - lb);
            }
            mx = max(mx, cnt);
            cnt = 0;
            for(int i = 0; i < tp2.size(); i++)
            {
                auto lb = upper_bound(all(tp1), tp2[i]);
                if(lb == tp1.end()) break;
                cnt += (tp1.end() - lb);
            }
            mx = max(mx, cnt);
        }
    }

    cout << mx << nl;
}


/// *********** Coded by Olium_MdioxideN ***********

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define nl '\n'
#define endl '\n'
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sci2(x,y) scanf("%d %d",&(x),&(y))
#define pr printf
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define F first
#define S second
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define vi vector<int>
#define pii pair<int,int>
#define mpii map<int,int>
#define elif else if
#define debug(x) cerr << "Debug: " << x << '\n';
#define intmx INT_MAX
#define pi 3.14159265358979323846D
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
template <typename type> type __lcm(type n1,type n2){return n1*(n2/gcd(n1,n2));}
ll nCr(int n, int r)
{
    int f1 = r, f2 = n-r;
    if(f2 > f1) swap(f2,f1);
    ll result = 1;
    for(int i = 1; i <= f2; i++)
    {
        result *= (i+f1);
        result /= i;
    }
    return result;
}
ll nPr(int n, int r, ll mod = 0)
{
    ll result = 1;
    for(int i = n-r+1; i <= n; i++) {result *= i; if(mod) result %= mod;}
    return result;
}
ll factorial(int n, ll modulo = 0)
{
    if(n == 0) return 1;
    if(modulo) return (n*factorial(n-1))%modulo;
    else return n*factorial(n-1);
}

//implementation of normal sieve_of_eratosthenes
int *primes = NULL;
bool *isPrime = NULL;
int pidx = 0;
void normal_sieve(int n)
{
    n+=5;
    isPrime = new bool[n];
    memset(isPrime, 1, n);
    int sq = sqrt(n);
    isPrime[0] = isPrime[1] = false;
    for(int i = 4; i < n; i+=2) isPrime[i] = false;
    for(int i = 3; i <= sq; i+=2) if(isPrime[i]) for(int j = i*i; j < n; j+=(i<<1)) isPrime[j] = false;
    //comment out the rest to fast up the sieve for 10e7
    int primeCount = 1;
    for(int i = 3; i < n; i+=2) primeCount+=(isPrime[i]);
    primes = new int[primeCount];
    primes[pidx++] = 2;
    for(int i = 3; i < n; i+=2) if(isPrime[i]) primes[pidx++] = i;
}

//implementation of bitwise sieve_of_eratosthenes
int *isbPrime = NULL;
#define Set(n) (isbPrime[n>>5]=isbPrime[n>>5] or (1<<(n%32)))
#define Chk(n) (isbPrime[n>>5]&(1<<(n%32)))
void bitwise_sieve(int n)
{
    n+=5;
    int array_size = (n>>5);
    isbPrime = new int[array_size];
    memset(isbPrime, 0, n>>3);
    int sq = sqrt(n);
    Set(0); Set(1);
    for(int i = 4; i < 64; i+=2) Set(i);
    for(int i = 2; i < array_size; i++) isbPrime[i] = isbPrime[1];
    for(int i = 3; i <= sq; i+=2) if(!Chk(i)) for(int j = i*i; j < n; j+=(i<<1)) Set(j);
}

/// * * *    Main Code Starts Now    * * *

#define MOD 10000007
#define MAX 10000010
void f();
int main()
{
    //sieve(MAX);
    fast;
    //in_file;
    //out_file;
    int t = 1;
    //cin >> t;
    forr(i,1,t)
    {
        //printf("Case %d: ", i);
        f();
    }
    return 0;
}

void f()
{
    string s;
    cin >> s;
    map<char,vector<int> > fr;
    for(int i = 0; i < s.size(); i++)
    {
        fr[s[i]].pb(i);
    }
    int mx = 0;
    for(auto it = fr.begin(); it != fr.end(); it++)
    {
        int nn = (int)((it->second).size());
        mx = max(mx, nn);
        for(auto itt = fr.begin(); itt != fr.end(); itt++)
        {
            vector<int> tp1 = it->second, tp2 = itt->second;
            int cnt = 0;
            for(int i = 0; i < tp1.size(); i++)
            {
                auto lb = upper_bound(all(tp2), tp1[i]);
                cnt += (tp2.end() - lb);
                if(lb == tp2.end()) break;
            }
            mx = max(mx, cnt);
            cnt = 0;
            for(int i = 0; i < tp2.size(); i++)
            {
                auto lb = upper_bound(all(tp1), tp2[i]);
                cnt += (tp1.end() - lb);
                if(lb == tp1.end()) break;
            }
            mx = max(mx, cnt);
        }
    }

    cout << mx << nl;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
string s;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
	}
	sort(num,num+26);
	reverse(num,num+26);
	ll ans=max(num[0],num[0]*num[1]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
int res[26][26];
string s;
int ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']=pre[i-1][s[i]-'a']+1;
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
int res[26][26];
string s;
int ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)pre[i][s[i]-'a']+=pre[i-1][s[i]-'a'];
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
ll res[26][26];
string s;
int ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]+=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=1;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
//	REP(i,s.size())
	//	cout<<pre[i][0]<<" "<<pre[i][1]<<endl;
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
ll res[26][26];
string s;
ll ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]+=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=1;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
//	REP(i,s.size())
	//	cout<<pre[i][0]<<" "<<pre[i][1]<<endl;
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
int res[26][26];
string s;
int ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]+=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=1;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
//	REP(i,s.size())
	//	cout<<pre[i][0]<<" "<<pre[i][1]<<endl;
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll num[26];
int pre[100100][26];
ll res[26][26];
string s;
ll ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]+=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=1;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
//	REP(i,s.size())
	//	cout<<pre[i][0]<<" "<<pre[i][1]<<endl;
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll num[26];
int pre[100100][26];
ll res[26][26];
string s;
ll ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]+=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=1;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i-1][j];
	}
//	REP(i,s.size())
	//	cout<<pre[i][0]<<" "<<pre[i][1]<<endl;
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int num[26];
int pre[100100][26];
int res[26][26];
string s;
int ans;
int main()
{
	cin>>s;
	REP(i,s.size())
	{
		num[s[i]-'a']++;
		pre[i][s[i]-'a']++;
		if(i)
			REP(j,26)
				pre[i][j]=pre[i-1][j];
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		REP(j,26)
			res[j][s[i]-'a']+=pre[i][j];
	}
	REP(i,26)
		ans=max(ans,num[i]);
	REP(i,26)
		REP(j,26)
			ans=max(ans,res[i][j]);
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
if(br<=2) mxsol=max(mxsol,br);
else mxsol=max(mxsol,br*(br-1)/2));
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
mxsol=max(mxsol,max(2,(br*(br-1))/2));
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
mxsol=max(mxsol,max(2,br*(br-1)/2));
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
mxsol=max(mxsol,max(2ll,1ll*br*(br-1)/2));
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
if(br<=2) mxsol=max(mxsol,br);
else mxsol=max(mxsol,1ll*br*(br-1)/2);
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
using namespace std;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
string s;
cin >> s;
ll mxsol=0;
for(int i=0; i<26; i++)
{
ll br=0;
for(int j=0; j<s.size(); j++)
if(s[j]==i+'a') br++;
if(br<=2) mxsol=max(mxsol,br);
else mxsol=max(mxsol,1ll*br*(br-1)/2));
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
  if(i!=j)
  {
   ll ca=0,sol=0;
   for(int k=0; k<s.size(); k++)
   {
   if(s[k]==i+'a') ca++;
   if(s[k]==j+'a') sol+=ca;
   }
   mxsol=max(mxsol,sol);
   }
}
}
cout << mxsol;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

ll cnt[26][26];
int occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 1;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[y];
		}
		++occ[x];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	for(int i = 0; i < 26; ++i) maxi(res, occ[i]);

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

ll cnt[26][26];
int occ[26];

void st()
{
   srand(time(NULL));
   freopen("1307C.inp", "w", stdout);
   sfo(i, 1, 100000) cout << 'j';
   cout << '\n';
}

int main()
{
   //freopen("1307C.inp", "r", stdin);
   //freopen("1307C.out", "w", stdout);
   ios_base::sync_with_stdio(0); cin.tie(nullptr);

   string s; cin >> s;

	ll res = 1;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[y];
		}
		++occ[x];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	for(int i = 0; i < 26; ++i) maxi(res, occ[i]);

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int cnt[26][26], occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 2;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[x];
		}
		++occ[s[i] - 'a'];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int cnt[26][26], occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 2;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[x];
		}
		++occ[s[i] - 'a'];
	}

	int res = 0;
	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int cnt[26][26], occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 1;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[y];
		}
		++occ[x];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int cnt[26][26], occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 2;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[y];
		}
		++occ[x];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	cout << res << '\n';

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

   return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int cnt[26][26], occ[26];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(nullptr);
   //freopen("task.inp", "r", stdin);

   string s; cin >> s;

	int res = 1;

	for(int i = 0; i < s.size(); ++i) {
		int x = s[i] - 'a';
		for(int y = 0; y < 26; ++y) {
			cnt[x][y] += occ[y];
		}
		++occ[x];
	}

	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			maxi(res, cnt[i][j]);
		}
	}

	for(int i = 0; i < 26; ++i) maxi(res, occ[i]);

	cout << res << '\n';

   return 0;
}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105],sum1[100005][105],cnt[26][26];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	rf(i,len,1){
		fr(j,0,25)sum1[i][j]=sum1[i+1][j];
		sum1[i][s[i]-'a']++;
	}
	int ans=0,ma1,ma2;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			if(i==j)continue;
			int s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum1[k+1][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;

}


/*Code by Codercjh*/
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	ll ans=0;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			ll s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum[len][j]-sum[k][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][26],sum1[100005][26];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	rf(i,len,1){
		fr(j,0,25)sum1[i][j]=sum1[i+1][j];
		sum1[i][s[i]-'a']++;
	}
	int ans=0,ma1,ma2;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,2,len){
		ma1=ma2=0;
		fr(j,0,25)ma1=max(ma1,sum[i-1][j]);
		fr(j,0,25)ma2=max(ma2,sum1[i][j]);
		ans=max(ans,ma1*ma2);
	}
	cout<<ans<<endl;
	return 0;

}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	ll ans=0;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			ll s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum[len][j]-sum1[k][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;

}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	ll ans=0;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			ll s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum[len][j]-sum[k][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105],sum1[100005][105],cnt[26][26];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	rf(i,len,1){
		fr(j,0,25)sum1[i][j]=sum1[i+1][j];
		sum1[i][s[i]-'a']++;
	}
	ll ans=0;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			if(i==j)continue;
			ll s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum1[k+1][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;

}


/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
int len,sum[100005][105],sum1[100005][105],cnt[26][26];
int main(){
    scanf("%s",s+1);
    int len=strlen(s+1);
	fr(i,1,len){
		fr(j,0,25)sum[i][j]=sum[i-1][j];
		sum[i][s[i]-'a']++;
	}
	rf(i,len,1){
		fr(j,0,25)sum1[i][j]=sum1[i+1][j];
		sum1[i][s[i]-'a']++;
	}
	ll ans=0;
	fr(i,0,25)ans=max(ans,sum[len][i]);
	fr(i,0,25){
		fr(j,0,25){
			ll s1=0;
			fr(k,1,len)
			    if(s[k]==i+'a')
			    	s1+=sum1[k+1][j];
            ans=max(ans,s1);
		}
	}
	cout<<ans<<endl;
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
	ll val,i,j;
}a[1000005];
ll cmp(node a,node b){
	return a.val > b.val;
}
ll ans[1000005];
int main(){
	ll n;
	while(~scanf("%lld",&n)){
		memset(ans,0,sizeof(ans));
		ll total = 0;
		for(ll i = 2;i <= 2 * n;i++){
			for(ll j = 1;j <= i - 1;j++){
				scanf("%lld",&a[total].val);
				a[total].i = i;
				a[total].j = j;
				total++;
			}
		}
		sort(a,a + total,cmp);
		for(ll i = 0;i < total;i++){
			ll x = a[i].i;
			ll y = a[i].j;
			if(!ans[x] && !ans[y]){
				ans[x] = y;
				ans[y] = x;
			}
		}
		printf("%lld",ans[1]);
		for(ll i = 2;i <= 2 * n;i++){
			printf(" %lld",ans[i]);
		}
		puts("");
	}
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1e6+10;
struct node
{
    int x;
    int y;
    int num;
}a[maxn];
int b[maxn];
bool cmp(node a,node b)
{
    return a.num>b.num;
}
int vis[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int k=0;
        memset(vis,0,sizeof(vis));
        for(int i=2; i<=2*n; i++)
        {
            for(int j=1; j<i; j++)
            {
                scanf("%d",&a[k].num);
                a[k].x=i;
                a[k].y=j;
                k++;
            }
        }
        sort(a,a+k,cmp);
        for(int i=0;i<k;i++)
        {
            if(vis[a[i].x]==0&&vis[a[i].y]==0)
            {
                vis[a[i].x]=1;
                vis[a[i].y]=1;
                b[a[i].x]=a[i].y;
                b[a[i].y]=a[i].x;
            }
        }
        for(int i=1;i<=2*n;i++)
        {
            printf("%d ",b[i]);
        }
        puts("");
    }
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
struct node
{
    int x;
    int y;
    int num;
}a[maxn];
int b[maxn];
bool cmp(node a,node b)
{
    return a.num>b.num;
}
int vis[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int k=0;
        memset(vis,0,sizeof(vis));
        for(int i=2; i<=2*n; i++)
        {
            for(int j=1; j<i; j++)
            {
                scanf("%d",&a[k].num);
                a[k].x=i;
                a[k].y=j;
                k++;
            }
        }
        sort(a,a+k,cmp);
        for(int i=0;i<k;i++)
        {
            if(vis[a[i].x]==0&&vis[a[i].y]==0)
            {
                vis[a[i].x]=1;
                vis[a[i].y]=1;
                b[a[i].x]=a[i].y;
                b[a[i].y]=a[i].x;
            }
        }
        for(int i=1;i<=2*n;i++)
        {
            printf("%d ",b[i]);
        }
        puts("");
    }
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=505;
struct node
{
    int x;
    int y;
    int num;
}a[maxn];
int b[maxn];
bool cmp(node a,node b)
{
    return a.num>b.num;
}
int vis[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int k=0;
        memset(vis,0,sizeof(vis));
        for(int i=2; i<=2*n; i++)
        {
            for(int j=1; j<i; j++)
            {
                scanf("%d",&a[k].num);
                a[k].x=i;
                a[k].y=j;
                k++;
            }
        }
        sort(a,a+k,cmp);
        for(int i=0;i<k;i++)
        {
            if(vis[a[i].x]==0&&vis[a[i].y]==0)
            {
                vis[a[i].x]=1;
                vis[a[i].y]=1;
                b[a[i].x]=a[i].y;
                b[a[i].y]=a[i].x;
            }
        }
        for(int i=1;i<=2*n;i++)
        {
            printf("%d ",b[i]);
        }
        puts("");
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
const int MOD = 998244353;
//int C[100001][500001];
//std::vector<ll> v[100000];
//ll n,k;
std::vector<bool> visit(1000,false);
struct node
{
    ll a,b,c,d;
    bool flag;

};

int solve(){
    ll n;
    cin>>n;
    std::vector<ll> v[8001];
    ll x;
    for(ll i=2;i<=2*n;i++){
        for(ll j=0;j<i-1;j++){
            cin>>x;
            v[i].push_back(x);
        }

    }
    std::vector<ll> ans(2*n);
    ll c=0;
     while(c<2*n){
          ll mx=INT_MIN;
          ll a,b;
    for(ll i=2;i<=2*n;i++){
      //  if(c==2*n)break;
        ll sz=v[i].size();

        for(ll j=0;j<sz;j++){
            if(visit[i]==true)
                break;
            if(visit[j+1]==true)
                continue;
            if(mx<v[i][j]){
                mx=v[i][j];
                a=i,b=j+1;
            }
        }

    }
    //cout<<mx<<" "<<a<<" "<<b<<endl;
  //  cout<<c<<endl;
    ans[a-1]=b;
    ans[b-1]=a;
    visit[a]=true;
    visit[b]=true;
    c+=2;

}
for(ll i=0;i<2*n;i++)
cout<<ans[i]<<" ";
cout<<endl;

return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t=1;
  //  cin>>t;
    while(t--){
        //cin>>n>>k;

       solve();

    }
    //cout<<__gcd(808 ,779)<<endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
const int MOD = 998244353;
//int C[100001][500001];
//std::vector<ll> v[100000];
//ll n,k;
std::vector<bool> visit(1000,false);
struct node
{
    ll a,b,c,d;
    bool flag;

};

int solve(){
    ll n;
    cin>>n;
    std::vector<ll> v[8001];
    ll x;
    for(ll i=2;i<=2*n;i++){
        for(ll j=0;j<i-1;j++){
            cin>>x;
            v[i].push_back(x);
        }

    }
    std::vector<ll> ans(2*n);
    ll c=0;
     while(c<2*n){
          ll mx=INT_MIN;
          ll a,b;
    for(ll i=2;i<=2*n;i++){
      //  if(c==2*n)break;
        ll sz=v[i].size();

        for(ll j=0;j<sz;j++){
            if(visit[i]==true)
                break;
            if(visit[j+1]==true)
                continue;
            if(mx<v[i][j]){
                mx=v[i][j];
                a=i,b=j+1;
            }
        }

    }
    cout<<mx<<" "<<a<<" "<<b<<endl;
  //  cout<<c<<endl;
    ans[a-1]=b;
    ans[b-1]=a;
    visit[a]=true;
    visit[b]=true;
    c+=2;

}
for(ll i=0;i<2*n;i++)
cout<<ans[i]<<" ";
cout<<endl;

return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t=1;
  //  cin>>t;
    while(t--){
        //cin>>n>>k;

       solve();

    }
    //cout<<__gcd(808 ,779)<<endl;
    return 0;

}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define f(i,a,b) for(long long int i = (a); i < (b); i++)
#define fd(i,a,b) for(long long int i = (a); i >= (b); i--)

typedef long long int   ll;
typedef pair<ll,ll>   ii;
typedef vector< ii >    vii;
typedef vector<ll>     vi;
typedef vector< vi >    vvi;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define allrev(a) a.rbegin(),a.rend()
#define SET(a,b) memset(a,b,sizeof(a))
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
/**** Harshit Mahajan (ash0904) ******/

#define nscan(n) scanf("%d",&n)
#define nscan2(n,m) scanf("%d%d",&n,&m)
#define nprint(n) printf("%d\n",n)
#define scan(n) scanf("%lld",&n)
#define scan2(n,m) scanf("%lld%lld",&n,&m)
#define print(n) printf("%lld\n",n)
#define print2(n,m) printf("%lld %lld\n",n,m)
#define br() printf("\n");
#define strin(s) scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll mod=1000000007;
double PI = 3.14159265358979323846264338327950288;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

vii arr;
ll ans[500]={0},cnt[1000008]={0};
int main()
{
  ll m,n,q,test,x;
  arr.resize(1000010);
  scan(n);
  f(i,2,2*n+1)
  {
    f(j,1,i)
    {
      scan(x);
      arr[x] = mp(i,j);
      cnt[x]=1;
    }
  }
  fd(i,1000007,1)
  {
    if(cnt[i]==1)
    {
      if(ans[arr[i].F]==0 && ans[arr[i].S]==0)
      {
        ans[arr[i].F]=arr[i].S;
        ans[arr[i].S]=arr[i].F;
      }
    }
  }
  f(i,1,2*n)
    printf("%lld ",ans[i]);
  print(ans[2*n]);
  return 0;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define f(i,a,b) for(long long int i = (a); i < (b); i++)
#define fd(i,a,b) for(long long int i = (a); i >= (b); i--)

typedef long long int   ll;
typedef pair<ll,ll>   ii;
typedef vector< ii >    vii;
typedef vector<ll>     vi;
typedef vector< vi >    vvi;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define allrev(a) a.rbegin(),a.rend()
#define SET(a,b) memset(a,b,sizeof(a))
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
/**** Harshit Mahajan (ash0904) ******/

#define nscan(n) scanf("%d",&n)
#define nscan2(n,m) scanf("%d%d",&n,&m)
#define nprint(n) printf("%d\n",n)
#define scan(n) scanf("%lld",&n)
#define scan2(n,m) scanf("%lld%lld",&n,&m)
#define print(n) printf("%lld\n",n)
#define print2(n,m) printf("%lld %lld\n",n,m)
#define br() printf("\n");
#define strin(s) scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll mod=1000000007;
double PI = 3.14159265358979323846264338327950288;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

vii arr;
ll ans[900]={0},cnt[1000010]={0};
int main()
{
  ll m,n,q,test,x;
  arr.resize(1000010);
  scan(n);
  f(i,2,2*n+1)
  {
    f(j,1,i)
    {
      scan(x);
      arr[x] = mp(i,j);
      cnt[x]=1;
    }
  }
  fd(i,1000007,1)
  {
    if(cnt[i]==1)
    {
      if(ans[arr[i].F]==0 && ans[arr[i].S]==0)
      {
        ans[arr[i].F]=arr[i].S;
        ans[arr[i].S]=arr[i].F;
      }
    }
  }
  f(i,1,2*n)
    printf("%lld ",ans[i]);
  print(ans[2*n]);
  return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=810;
struct node{
	int x,y,d;
}arr[maxn*maxn];
int belong[maxn];

bool cmp(node a,node b)
{
	return a.d>b.d;
}

int main()
{
	int i,j,k,n,cnt;
	while ( scanf("%d",&n)!=EOF )
	{
		memset(belong,0,sizeof(belong));
		cnt=0;
		for ( i=2;i<=2*n;i++ )
			for ( j=1;j<i;j++ )
			{
				scanf("%d",&arr[++cnt].d);
				arr[cnt].x=i;
				arr[cnt].y=j;
			}
		sort(arr+1,arr+1+cnt,cmp);
		for ( i=1;i<=cnt;i++ )
		{
			if ( belong[arr[i].x] || belong[arr[i].y] ) continue;
			else {
				belong[arr[i].x]=arr[i].y;
				belong[arr[i].y]=arr[i].x;
			}
		}
		for ( i=1;i<=2*n;i++ )
		{
			printf("%d",belong[i]);
			if ( i!=2*n ) printf(" ");
			else printf("\n");
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=410;
struct node{
	int x,y,d;
}arr[maxn*maxn];
int belong[maxn];

bool cmp(node a,node b)
{
	return a.d>b.d;
}

int main()
{
	int i,j,k,n,cnt;
	while ( scanf("%d",&n)!=EOF )
	{
		memset(belong,0,sizeof(belong));
		cnt=0;
		for ( i=2;i<=2*n;i++ )
			for ( j=1;j<i;j++ )
			{
				scanf("%d",&arr[++cnt].d);
				arr[cnt].x=i;
				arr[cnt].y=j;
			}
		sort(arr+1,arr+1+cnt,cmp);
		for ( i=1;i<=cnt;i++ )
		{
			if ( belong[arr[i].x] || belong[arr[i].y] ) continue;
			else {
				belong[arr[i].x]=arr[i].y;
				belong[arr[i].y]=arr[i].x;
			}
		}
		for ( i=1;i<=2*n;i++ )
		{
			printf("%d",belong[i]);
			if ( i!=2*n ) printf(" ");
			else printf("\n");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,b,ar[505][505],a[500];
    int cnt = -1;
    vector<int>v;
    cin>>n;
    for(i=1; i<=2*n; i++)
       a[i] = 0;
    for(i=1; i<2*n; i++)
        for(j=1; j<=i; j++)
        {
            cin>>ar[i][j];
            v.push_back(ar[i][j]);
            cnt++;
        }
    sort(v.begin(),v.end());
    int cnt1 = 0;
    while(1)
    {
        int temp = v[cnt];
        for(i=1; i<2*n; i++)
            for(j=1; j<=i; j++)
            {
                   if(temp == ar[i][j])
                   {
                        if(a[i+1] == 0 && a[j] == 0)
                         {
                                a[j] = i+1;
                                a[i+1] = j;
                                cnt1++;
                         }
                         goto eme;
                   }
            }
            eme:
               cnt--;
             if(cnt1 == n)
              break;
    }
      for(i=1; i<2*n; i++)
         cout<<a[i]<<" ";
      cout<<a[2*n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000000][2];

int main()
{
    ll cnt=0,n,i,j,b,ar[850],z = 1;
    vector<int>v;
    cin>>n;
    for(i=1; i<=2*n; i++)
        ar[i] = 0;

    for( i=1; i<=2*n; i++)
    {
        for(j = 1; j<i; j++)
        {
            cin>>b;
            a[b][0] = i;
            a[b][1] = j;
            v.push_back(b);
            cnt++;
        }
    }
    sort(v.begin(),v.end());
    int p = n;
    while(n)
    {
        int x = v[--cnt];
        int m = a[x][0];
         int y = a[x][1];
        if((ar[m] == 0) && (ar[y]==0))
        {
               ar[m] = y;
               ar[y] = m;
            n--;
        }
    }
    for(i=1; i<=2*p; i++)
    {
        cout<<ar[i];
        if(i<2*p)
            cout<<" ";
    }
    cout<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll a[1000000][2];

int main()
{
    ll cnt=0,n,i,j,b,ar[850],z = 1;
    vector<int>v;
    cin>>n;
    for(i=1; i<=2*n; i++)
        ar[i] = 0;

    for( i=1; i<=2*n; i++)
    {
        for(j = 1; j<i; j++)
        {
            cin>>b;
            a[b][0] = i;
            a[b][1] = j;
            v.pb(b);
            cnt++;
        }
    }
    sort(v.begin(),v.end());
    int p = n;
    while(n)
    {
        int x = v[--cnt];
        int m = a[x][0];
         int y = a[x][1];
        if((ar[m] == 0) && (ar[y]==0))
        {
               ar[m] = y;
               ar[y] = m;
            n--;
        }
    }
    for(i=1; i<=2*p; i++)
    {
        cout<<ar[i];
        if(i<2*p)
            cout<<" ";
    }
    cout<<endl;

    return 0;
}


/*#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000000][2];

int main()
{
    ll cnt=0,n,i,j,b,ar[850],z = 1;
    vector<int>v;
    cin>>n;
    for(i=1; i<=2*n; i++)
        ar[i] = 0;

    for( i=1; i<=2*n; i++)
    {
        for(j = 1; j<i; j++)
        {
            cin>>b;
            a[b][0] = i;
            a[b][1] = j;
            v.push_back(b);
            cnt++;
        }
    }
    sort(v.begin(),v.end());
    int p = n;
    while(n)
    {
        int x = v[--cnt];
        int m = a[x][0];
         int y = a[x][1];
        if((ar[m] == 0) && (ar[y]==0))
        {
               ar[m] = y;
               ar[y] = m;
            n--;
        }
    }
    for(i=1; i<=2*p; i++)
    {
        cout<<ar[i];
        if(i<2*p)
            cout<<" ";
    }
    cout<<endl;

    return 0;
}*/

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,b,ar[505][505],a[850];
    int cnt = 0;
    vector<int>v;
    cin>>n;
    for(i=1; i<=2*n; i++)
        a[i] = 0;
    for(i=1; i<=2*n; i++)
        for(j=1; j<i; j++)
        {
            cin>>ar[i][j];
            v.push_back(ar[i][j]);
            cnt++;
        }
    sort(v.begin(),v.end());
    int cnt1 = 0;
    while(1)
    {
        int temp = v[--cnt];
        for(i=1; i<=2*n; i++)
        {
            for(j=1; j<i; j++)
            {
                if(temp == ar[i][j])
                {
                    if(a[i] == 0 && a[j] == 0)
                    {
                        a[j] = i;
                        a[i] = j;
                        cnt1++;
                    }
                    goto eme;
                }
            }
        }
eme:
        if(cnt1 == n)
            break;
  }
    for(i=1; i<2*n; i++)
        cout<<a[i]<<" ";
    cout<<a[2*n]<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>

using namespace std;

vector<int> teamsFunc(vector<map<int,pair<int,int>>> &vec, int teams){
    //vector<int> res(teams*2,0);
    vector<int> res;
    res.resize(teams*2);
    int max = 0;
    bool zeroIsAvailable = true;
    pair<int,int> pair = {0,0};
    for(int j=0;j<teams;j++){
        for(int i=0;i<vec.size();i++){
        if(!vec[i].empty() && vec[i].rbegin()->first > max){
            int ind = vec[i].rbegin()->second.second;
            while((ind-1 >= 0 && vec[ind-1].empty()) || (ind==0 && zeroIsAvailable==false)){
                int val = vec[i].rbegin()->first;
                vec[i].erase(val);
                if(vec[i].empty()){
                    std::pair<int,std::pair<int,int>> coppia = make_pair(0,make_pair(0,0));
                    vec[i].insert(coppia);
                    break;
                }
                ind = vec[i].rbegin()->second.second;
            }
        }

        if(!vec[i].empty() && vec[i].rbegin()->first > max){
            max = vec[i].rbegin()->first;
            pair = vec[i].rbegin()->second;
            }

        }

    res[pair.first] = pair.second+1;
    res[pair.second] = pair.first+1;
    if(pair.first!=0) vec[pair.first-1].clear();
    if(pair.second!=0) vec[pair.second-1].clear();
    if(pair.first==0 || pair.second==0) zeroIsAvailable=false;
    max = 0;

}

   return res;
}

int main(int argc, char *argv[]) {
    int teams;
    cin >> teams;
    vector<map<int,pair<int,int>>> vector;
    for(int i=0;i<(2*teams-1);i++){
        map<int,pair<int,int>> tmp;
        vector.push_back(tmp);
    }
    int el = 1;
    int mate = 0;
    for(int i=0;i<2*teams-1;i++){
        for(int j=0;j<el;j++){
            int tmp;
            cin >> tmp;
            pair<int,pair<int,int>> coppia = make_pair(tmp,make_pair(i+1,mate));
            vector[i].insert(coppia);
            mate++;
        }
        mate=0;
        el++;
    }

    std::vector<int> result = teamsFunc(vector,teams);
    for(auto &e : result){
        cout << e << " ";
    }
    cout << endl;

	return 0;

}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>

using namespace std;

vector<int> teamsFunc(vector<map<int,pair<int,int>>> &vec, int teams){
    vector<int> res(teams*2,0);
    int max = 0;
    bool zeroIsAvailable = true;
    pair<int,int> pair = {0,0};
    for(int j=0;j<teams;j++){
        cout << "passato" << endl;
        for(int i=0;i<vec.size();i++){
        if(!vec[i].empty() && vec[i].rbegin()->first > max){
            int ind = vec[i].rbegin()->second.second;
            while((ind-1 >= 0 && vec[ind-1].empty()) || (ind==0 && zeroIsAvailable==false)){
                int val = vec[i].rbegin()->first;
                vec[i].erase(val);
                if(vec[i].empty()){
                    std::pair<int,std::pair<int,int>> coppia = make_pair(0,make_pair(0,0));
                    vec[i].insert(coppia);
                    break;
                }
                ind = vec[i].rbegin()->second.second;
            }
        }

        if(!vec[i].empty() && vec[i].rbegin()->first > max){
            max = vec[i].rbegin()->first;
            pair = vec[i].rbegin()->second;
            }

        }
    cout << "inserisco=" << pair.first << " " << pair.second << " che hanno valore" << max << endl;
    res[pair.first] = pair.second+1;
    res[pair.second] = pair.first+1;
    if(pair.first!=0) vec[pair.first-1].clear();
    if(pair.second!=0) vec[pair.second-1].clear();
    if(pair.first==0 || pair.second==0) zeroIsAvailable=false;
    max = 0;

    cout << "SITUAZIONE:" << endl;
      for(auto &e : res){
        cout << e << " ";
    }
    cout << endl << "FINE SITUAZIONE" << endl << endl;
}

    // for(auto &e : res){
    //     cout << e << " ";
    // }
   return res;
}

int main(int argc, char *argv[]) {
// 2
// 6
// 1 2
// 3 4 5

//3 487060 3831 161856 845957 794650 976977 83847 50566 691206 498447 698377 156232 59015 382455 626960
    int teams;
    cin >> teams;
    vector<map<int,pair<int,int>>> vector;
    for(int i=0;i<(2*teams-1);i++){
        map<int,pair<int,int>> tmp;
        vector.push_back(tmp);
    }
    int el = 1;
    int mate = 0;
    for(int i=0;i<2*teams-1;i++){
        for(int j=0;j<el;j++){
            int tmp;
            cin >> tmp;
            pair<int,pair<int,int>> coppia = make_pair(tmp,make_pair(i+1,mate));
            vector[i].insert(coppia);
            mate++;
        }
        mate=0;
        el++;
    }
    for(auto &el : vector){
        for(auto &e : el){
            cout << "pair = " << e.second.first << " - " << e.second.second << " value = " << e.first << endl;
        }
    }
    std::vector<int> result = teamsFunc(vector,teams);
    for(auto &e : result){
        cout << e << " ";
    }
    cout << endl;

    // for(auto &e : vector){
    //     for(auto &el : e){
    //         cout << "valore = " << el.first << " con compagno = " << el.second << endl;
    //     }
    // }

	return 0;

}