#include <iostream>
using namespace std;
int main()
{
	int n, x;
	cin >> n >> x;
	unsigned short int a[100000];
	short i, j, q = 0;
	cin >> a[0];
	for (i = 1; i < n; i++)
	{
		cin >> a[i];
		for (j = 0; j < i; j++)
		{
			if ((a[i] ^ a[j]) == x)
				q++;
		}
	}
	cout << q;
}


#include <iostream>
using namespace std;
int main()
{
    long n,res,k,a[1000000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        ans+=a[res^k];
        a[k]++;
    }
    cout<<ans<<endl;
}


#include <iostream>
using namespace std;
int main()
{
    int n,res,k,a[100000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        res[k]++;
        ans+=a[res^k];
    }
    cout<<ans<<endl;a
}


#include <iostream>
using namespace std;
int main()
{
    long n,res,k,a[100000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        ans+=a[res^k];
        a[k]++;
    }
    cout<<ans<<endl;
}


#include <iostream>
using namespace std;
int main()
{
    int n,res,k,a[100000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        a[k]++;
        ans+=a[res^k];
    }
    cout<<ans<<endl;
}


import java.util.Scanner;

public class Xor {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        short n = scanner.nextShort();
        short x = scanner.nextShort();
        short[] a = new short[n];
        int i, j, q = 0;
        a[0]=scanner.nextShort();
        for (i = 1; i < n; i++) {
            a[i] = scanner.nextShort();
            for (j = 0; j < i; j++) {
                if ((a[i] ^ a[j]) == x)
                    q++;
            }
        }
        System.out.println(q);
    }
}


#include <iostream>
using namespace std;
int main()
{
	int n, x;
	cin >> n >> x;
	int a[100000];
	short i, j, q = 0;
	cin >> a[0];
	for (i = 1; i < n; i++)
	{
		cin >> a[i];
		for (j = 0; j < i; j++)
		{
			if ((a[i] ^ a[j]) == x)
				q++;
		}
	}
	cout << q;
}


#include <iostream>
using namespace std;
int main()
{
    int n,res,k,a[100000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        ans+=a[res^k];
        a[k]++;
    }
    cout<<ans<<endl;
}


#include <iostream>
using namespace std;
int main()
{
	int n, x;
	cin >> n >> x;
	int a[100000];
	short i, j;
	int q = 0;
	cin >> a[0];
	for (i = 1; i < n; i++)
	{
		cin >> a[i];
		for (j = 0; j < i; j++)
		{
			if ((a[i] ^ a[j]) == x)
				q++;
		}
	}
	cout << q;
}


#include <iostream>
using namespace std;
int main()
{
	unsigned short int n, x;
	cin >> n >> x;
	unsigned short int a[100000];
	int i, j;
	int q = 0;
	cin >> a[0];
	for (i = 1; i < n; i++)
	{
		cin >> a[i];
		for (j = 0; j < i; j++)
		{
			if ((a[i] ^ a[j]) == x)
				q++;
		}
	}
	cout << q;
}


#include <iostream>
using namespace std;
int main()
{
	int n, x;
	cin >> n >> x;
	short a[100000];
	short i, j, q = 0;
	cin >> a[0];
	for (i = 1; i < n; i++)
	{
		cin >> a[i];
		for (j = 0; j < i; j++)
		{
			if ((a[i] ^ a[j]) == x)
				q++;
		}
	}
	cout << q;
}


#include <iostream>
using namespace std;
int main()
{
    long long n,res,k,a[1000000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        ans+=a[res^k];
        a[k]++;
    }
    cout<<ans<<endl;
}


#include <iostream>
using namespace std;
int main()
{
    int n,res,k,a[100000],ans=0;
    cin>>n>>res;
    for(;n>0;n--)
    {
        cin>>k;
        res[k]++;
        ans+=a[res^k];
    }
    cout<<ans<<endl;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	int result = 0;
	for (int i = 0; i < n; ++i) {
		if (mas[i] ^ x > 0 && mas[i] ^ x <= 100000) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	long long result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) > 0 && (mas[i] ^ x) <= 100000 && cnt[mas[i]] > 0) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	int result = 0;
	for (int i = 0; i < n; ++i) {
		if (mas[i] ^ x > 0 && mas[i] ^ x < 100000) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	//cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	long long result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) > 0 && (mas[i] ^ x) <= 100000) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	long long result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) > 0 && (mas[i] ^ x) <= 100000) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	//cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	int result = 0;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		if ((mas[i] ^ x) <= 100000) {
			result += cnt[mas[i] ^ x];
		}
		cnt[mas[i]]++;
	}

	cout << result;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	//cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	long long result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) > 0 && (mas[i] ^ x) <= 100000) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			if (x != 0) {
				result += a * b;
			}
			else {
				result += a * (a - 1);
			}
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	//cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	long long result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) <= 100000) {
			result += cnt[mas[i] ^ x];
		}
	}

	if (x != 0) {
		cout << result / 2 << endl;
	}
	else {
		cout << result << endl;
	}

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	int result = 0;
	for (int i = 0; i < n; ++i) {
		if ((mas[i] ^ x) > 0 && (mas[i] ^ x) <= 100000 && cnt[mas[i]] > 0) {
			int a = cnt[mas[i]];
			int b = cnt[mas[i] ^ x];
			result += a * b;
			cnt[mas[i]] = 0;
		}
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		cnt[mas[i]]++;
	}

	int result = 0;
	for (int i = 0; i < n; ++i) {
		int a = cnt[mas[i]];
		int b = cnt[mas[i] ^ x];
		result += a * b;
		cnt[mas[i]] = 0;
	}

	cout << result << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int mas[100010];
int cnt[100010];

int main() {

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

	memset(cnt, 0, sizeof(cnt));

	//cout << (2 ^ 0) << endl;

	int n, x;
	cin >> n >> x;
	long long result = 0;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		if ((mas[i] ^ x) <= 100000) {
			result += cnt[mas[i] ^ x];
		}
		cnt[mas[i]]++;
	}

	cout << result;

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		vector<int>nums,results;
		int temp;
		map<int,int>records;
		for(int i=0;i<n;i++)
		{
			cin>>temp;
			nums.push_back(temp^m);
			records[temp]++;
		}
		long long  count=0;
		int decrease=0;
		if(m==0)
			decrease=1;
		for(int i=0;i<n;i++)
		{
			count+=(records[nums[i]]-decrease);
		}
		count/=2;
		cout<<count<<endl;
	}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		vector<int>nums,results;
		int temp;
		map<int,int>records;
		for(int i=0;i<n;i++)
		{
			cin>>temp;
			nums.push_back(temp^m);
			records[temp]++;
		}
		int count=0;
		for(int i=0;i<n;i++)
		{
			count+=records[nums[i]];
		}
		count/=2;
		cout<<count<<endl;
	}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		vector<int>nums,results;
		int temp;
		map<int,int>records;
		for(int i=0;i<n;i++)
		{
			cin>>temp;
			nums.push_back(temp^m);
			records[temp]++;
		}
		long long  count=0;
		for(int i=0;i<n;i++)
		{
			count+=records[nums[i]];
		}
		count/=2;
		cout<<count<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int C(int n, int k)
{
	if (k == 0 || k == n)
		return 1;
	else
		return C(n - 1, k - 1) + C(n - 1, k);
}
int main() {
	int n, x, a, sum = 0;
	cin >> n >> x;
	vector<int> b(100001, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
	}
	if (x == 0) {
		for (int i = 0; i < 100001; i++) {
			if (b[i] > 1)
				sum += C(b[i], 2);
		}
		cout << sum;
		return 0;
	}
	int xor;
	for (int i = 0; i < 100001; i++) {
		xor = i^x;
		if (xor < i) continue;
		if (b[i] && b[xor]) {
			sum += b[i]*b[xor];
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

long long C(int n, int k)
{
	return n*(n-1) / 2;
}
int main() {
	int n, x, a;
	long long sum = 0;
	cin >> n >> x;
	vector<int> b(100001, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
	}
	if (x == 0) {
		for (int i = 0; i < 100001; i++) {
			if (b[i] > 1)
				sum += C(b[i], 2);
		}
		cout << sum;
		return 0;
	}
	int xor;
	for (int i = 0; i < 100001; i++) {
		xor = i^x;
		if (xor < i || xor > 100000) continue;
		if (b[i] && b[xor]) {
			sum += b[i]*b[xor];
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

long long C(long long n, int k)
{
	return n*(n-1) / 2;
}
int main() {
	int n, x, a;
	long long sum = 0;
	cin >> n >> x;
	vector<int> b(100001, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
	}
	if (x == 0) {
		for (int i = 0; i < 100001; i++) {
			if (b[i] > 1)
				sum += C(b[i], 2);
		}
		cout << sum;
		return 0;
	}
	int xor;
	for (int i = 0; i < 100001; i++) {
		xor = i^x;
		if (xor < i || xor > 100000) continue;
		if (b[i] && b[xor]) {
			sum += b[i]*b[xor];
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

long long C(int n, int k)
{
	return n*(n-1) / 2;
}
int main() {
	int n, x, a;
	long long sum = 0;
	cin >> n >> x;
	vector<int> b(100001, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
	}
	if (x == 0) {
		for (int i = 0; i < 100001; i++) {
			if (b[i] > 1)
				sum += C(b[i], 2);
		}
		cout << sum;
		return 0;
	}
	int xor;
	for (int i = 0; i < 100001; i++) {
		xor = i^x;
		if (xor < i) continue;
		if (b[i] && b[xor]) {
			sum += b[i]*b[xor];
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

long long C(long long n, int k)
{
	return n*(n-1) / 2;
}
int main() {
	int n, x, a;
	long long sum = 0;
	cin >> n >> x;
	vector<int> b(100001, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
	}
	if (x == 0) {
		for (int i = 0; i < 100001; i++) {
			if (b[i] > 1)
				sum += C(b[i], 2);
		}
		cout << sum;
		return 0;
	}
	int xor;
	for (int i = 0; i < 100001; i++) {
		xor = i^x;
		if (xor < i || xor > 100000) continue;
		if (b[i] && b[xor]) {
			sum += (long long)b[i]*b[xor];
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;
long long a[200001], b[200001];

int main()
{
   long long n, x,ans=0;
   cin>>n>>x;
   for (int i=1; i<=n; i++)
   {
	   cin>>a[i];
	   b[a[i]]++;
   }
   for (int i=1; i<=n; i++)
   {
       ans+=b[a[i]^x];
   }

    ans/=2;
    if (x==0)
    ans-=n;

   cout<<ans;

   return 0;

}


#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;
long long a[100001];

int main()
{
   long long n, x,ans=0;
   cin>>n>>x;
   for (int i=1; i<=n; i++)
   {
	   cin>>a[i];
   }
   for (int i=1; i<=n; i++)
   {
	   for (int j=i+1; j<=n; j++)
	   {
		   if (((a[i])^(a[j]))==x)
			   ans++;
	   }
   }

   cout<<ans;

   return 0;

}


#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;
long long a[4]={6, 8, 4, 2};

int main()
{
   long long n, x,ans=0;
   cin>>n>>x;
   for (int i=1; i<=n; i++)
   {
	   cin>>a[i];
   }
   for (int i=1; i<=n; i++)
   {
	   for (int j=i+1; j<=n; j++)
	   {
		   if (((a[i])^(a[j]))==x)
			   ans++;
	   }
   }

   cout<<ans;

   return 0;

}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
#define P pair<int,int>
#define ll long long

using namespace std;
bool cmp(ll x, ll y)
{
	return x > y;
}

ll m[30][30];
char a[10000005];
int main()
{

	scanf("%s",&a);
	map<char, ll>mp;
	mp.clear();
	ll tot = 1;
	ll b[30];
	MEM(b, 0);
	ll r = strlen(a);
	ll max = 0;
	for (ll i = 0; i < r; i++)
	{
		if (mp[a[i]])
			b[mp[a[i]]]++;
		else
		{
			mp[a[i]] = tot++;
			b[mp[a[i]]] = 1;
		}
		for (ll j = 1; j < 30; j++)
		{
			if (j != mp[a[i]])
				m[j][mp[a[i]]] += b[j];
		}
	}
	ll max1 = 0;
	sort(b, b + 27, cmp);
	if (b[1] == 0)
		cout << b[0];
	else
	{
		for (int i = 0; i < 30; i++)
			for (int j = 0; j < 30; j++)
			{
				if (m[i][j] > max1)
					max1 = m[i][j];
			}
		if (b[0] > max1)
			max1 = b[0];
		cout << max1;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

ll d1[26], now[26];
ll d2[26][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    fo(i, 0, s.size())
    {
        d1[s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        now[s[i] - 'a'] += 1;
        fo(j, 0, 26)
        {
            d2[s[i] - 'a'][j] += d1[j] - now[j];
        }
    }

    ll maxx = 0;
    fo(i, 0, 26)
    {
        fo(j, 0, 26)
        {
            maxx = max(maxx, d1[i]);
            maxx = max(maxx, d2[i][j]);
        }
    }
    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[100001][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, ll> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    for (int i = s.size() - 1; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    ll maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[100001][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, ll> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    d[s.size() - 1][s.back() - 'a'] += 1;
    for (int i = s.size() - 2; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    ll maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[100000][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, ll> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    d[s.size() - 1][s.back() - 'a'] += 1;
    for (int i = s.size() - 2; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    ll maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

/*

*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<string, int> m;
    fo(i, 0, s.size())
    {
        string t = string(1, s[i]);
        if (m.find(t) == m.end())
            m.insert({t, 0});
        m[t] += 1;

        fo(j, i + 1, s.size())
        {
            string t2 = t + s[j];
            if (m.find(t2) == m.end())
                m.insert({t2, 0});
            m[t2] += 1;
        }
    }

    int maxx = 0;
    for(auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[111111][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, ll> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    memset(d, 0, sizeof(d));
    d[s.size() - 1][s.back() - 'a'] += 1;
    for (int i = s.size() - 2; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    ll maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[100000][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<string, int> m;
    fo(i, 0, s.size())
    {
        string t = string(1, s[i]);
        if (m.find(t) == m.end())
            m.insert({t, 0});
        m[t] += 1;
    }

    d[s.size() - 1][s.back() - 'a'] += 1;
    for (int i = s.size() - 1; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        string t = string(1, s[i]);
        fo(j, 0, 26)
        {
            if (d[i + 1][j] < 1)
                continue;
            string _this = t + char(j + 'a');
            if (m.find(_this) == m.end())
                m.insert({_this, 0});
            m[_this] += d[i + 1][j];
        }
    }

    int maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[111111][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, int> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    memset(d, 0, sizeof(d));
    d[s.size() - 1][s.back() - 'a'] += 1;
    for (int i = s.size() - 2; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    int maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)
#define fc(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)
#define endl '\n'
using ll = long long;

int d[100001][26];

/*
*/
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    map<int, ll> m;
    fo(i, 0, s.size())
    {
        if (m.find(s[i]) == m.end())
            m.insert({s[i], 0});
        m[s[i]] += 1;
    }
    for (int i = s.size() - 2; 0 <= i; --i)
    {
        fo(j, 0, 26)
        {
            d[i][j] = d[i + 1][j];
        }
        d[i][s[i] - 'a'] += 1;
    }

    fo(i, 0, s.size())
    {
        const int t = s[i] * 100;
        fo(j, 0, 26)
        {
            if (m.find(t + j) == m.end())
                m.insert({t + j, 0});
            m[t + j] += d[i + 1][j];
        }
    }

    ll maxx = 0;
    for (auto i : m)
    {
        maxx = max(maxx, i.second);
    }

    cout << maxx;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt1=0,cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

                cnt1=0,cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                //swap(a,b);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                swap(a,b);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=p;
                b=j;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200];

    memset(mp,0,sizeof(mp));

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;

    ll res=0;

    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);

            res=max(res,mp[i]);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                   // if(p==j)continue;
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                swap(a,b);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                //swap(v[a],v[b]);

                swap(a,b);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                swap(a,b);

                  //swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

  for(i=0; i<n; i++)
   {
       ara[str[i]-'a'][i+1]++;
   }

   for(i=0; i<26; i++)
   {
       ll sum=0;

       ara[i][0]=sum;

       for(j=1; j<=n; j++)
       {
           sum+=ara[i][j];

           ara[i][j]=sum;
       }
   }

  ll ans=0;

   for(i=2; i<=n; i++)
   {
      ll pos=0,l=0,r=0,left=0,right=0,posr=0,posl=0;

      for(j=0; j<26; j++)
      {
          ll sum=ara[j][n];

          left=ara[j][i-1];

          right=sum-left;

          if(l<left)
          {
              posl=j;

              l=left;
          }

            if(r<right)
          {
              posr=j;

              r=right;
          }
      }

     // cout<<l<<" "<<r<<endl;

      if(posl==posr)
        sum=l+r;

      else sum=(l*r);

      ans=max(sum,ans);
   }

   cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=0; p<v.size(); p++)
            {
                    if(p==j)continue;
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                swap(a,b);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=p;
                b=j;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=0;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt1=0,cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

                cnt1=0,cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200];

    memset(mp,0,sizeof(mp));

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;

    ll res=0;

    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);

            res=max(res,mp[i]);
        }
    }

    ll ans=0;
   // sort(vll(v),);

        for(j=0; j<v.size(); j++)
        {
          a=j;

          res=max(res,v[a].F);

            for(p=0; p<v.size(); p++)
            {
               b=p;

               //ll cnt1=v[a].F;
               ll cnt2=v[b].F,ans=0;

              // cout<<cnt2<<endl;

               for(i=0; i<n; i++)
               {
                   if(v[b].S==str[i])
                    cnt2--;

                   if(v[a].S==str[i] && cnt2>0)
                   {
                       ans+=cnt2;

                   }

               }

               res=max(res,ans);

            }
        }

        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
typedef unsigned long long ll;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                //swap(v[a],v[b]);

                swap(a,b);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                swap(a,b);

                  //swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200];

    memset(mp,0,sizeof(mp));

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;

    ll res=0;

    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);

            res=max(res,mp[i]);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                   // if(p==j)continue;
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

               res=max3(res,ans,sum);

              //  swap(a,b);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=0;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {
    ll res=v[0].F;

     for(j=0; j<v.size(); j++)
     {

         for(p=j+1; p<v.size(); p++){
          a=j;
          b=p;

          ans=0;
         char aa=v[a].S,bb=v[b].S;

         ll cnt1=0,cnt2=v[b].F;

     for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[a],v[b]);

        aa=v[a].S,bb=v[b].S;

        cnt1=0,cnt2=v[b].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

        // cout<<sum<<" "<<ans<<endl;

         ans=max3(sum,ans,v[b].F);

         ans=max(ans,v[a].F);

         res=max(res,ans);
         }
     }

  cout<<res<<endl;

      }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {

           ans=0;
         char aa=v[0].S,bb=v[1].S;

         ll cnt1=0,cnt2=v[1].F;

     for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[0],v[1]);

        aa=v[0].S,bb=v[1].S;

        cnt1=0,cnt2=v[1].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

        // cout<<sum<<" "<<ans<<endl;

         ans=max3(sum,ans,v[1].F);

         ans=max(ans,sum);

   cout<<ans<<endl;
      }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {

           ans=0;
         char aa=v[0].S,bb=v[1].S;

         ll cnt1=0,cnt2=v[1].F;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[0],v[1]);

        aa=v[0].S,bb=v[1].S;

        cnt1=0,cnt2=v[1].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

        // cout<<sum<<" "<<ans<<endl;

         ans=max3(sum,ans,v[1].F);

   cout<<ans<<endl;
      }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {

           ans=0;
         char aa=v[0].S,bb=v[1].S;

         ll cnt1=0,cnt2=v[1].F;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[0],v[1]);

        aa=v[0].S,bb=v[1].S;

        cnt1=0,cnt2=v[1].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

        // cout<<sum<<" "<<ans<<endl;

         ans=max(sum,ans);
      }

   cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200];

    memset(mp,0,sizeof(mp));

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;

    ll res=0;

    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);

            res=max(res,mp[i]);
        }
    }

    ll ans=0;
   // sort(vll(v),);

    if(v.size()==1)
        cout<<n<<endl;

    else
    {

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                   // if(p==j)continue;
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa && cnt2>0)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

              //  swap(a,b);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {

           ans=0;
         char aa=v[0].S,bb=v[1].S;

         ll cnt1=0,cnt2=v[0].F;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[0],v[1]);

        aa=v[0].S,bb=v[1].S;

        cnt1=0,cnt2=v[0].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         ans=max(sum,ans);
      }

   cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

   fastread();

   ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

     string str;

   bool flag=true;

   cin>>str;

   n=str.size();

   ll mp[200]={0};

      for(i=0; i<n; i++)
      {
          mp[str[i]]++;
      }
    vector<pll>v;
      for(i=97; i<=122; i++)
      {
          if(mp[i])
            {
                char ch=i;
                v.eb(mp[i],ch);
            }
      }

      ll ans=0;
      sort(vll(v),greater<pll>());

      if(v.size()==1)cout<<n<<endl;

      else
      {
    ll res=v[0].F;

     for(j=1; j<v.size(); j++)
     {
          a=j-1;
          b=j;

          ans=0;
         char aa=v[a].S,bb=v[b].S;

         ll cnt1=0,cnt2=v[b].F;

     for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 ans+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

         swap(v[a],v[b]);

        aa=v[a].S,bb=v[b].S;

        cnt1=0,cnt2=v[b].F;

        sum=0;

         for(i=0; i<n; i++)
         {
             if(str[i]==aa)
             {
//cout<<aa<<" "<<str[i]<<endl;
                 sum+=(cnt2);
             }
             else if(str[i]==bb)
                cnt2--;
         }

        // cout<<sum<<" "<<ans<<endl;

         ans=max3(sum,ans,v[b].F);

         ans=max(ans,v[a].F);

         res=max(res,ans);
     }

  cout<<res<<endl;

      }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i=97; i<=122; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v),greater<pll>());

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j; p<v.size(); p++)
            {
                a=j;
                b=p;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt1=0,cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

                cnt1=0,cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                // cout<<sum<<" "<<ans<<endl;

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);
            }
        }

        cout<<res<<endl;

    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,char>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define F first
#define S second
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define pb push_back
#define eb emplace_back
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>

const int Max = 1e5 + 10;

const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

ll ara[26][Max+10];
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q;

    string str;

    bool flag=true;

    cin>>str;

    n=str.size();

    ll mp[200]= {0};

    for(i=0; i<n; i++)
    {
        mp[str[i]]++;
    }
    vector<pll>v;
    for(i='a'; i<='z'; i++)
    {
        if(mp[i])
        {
            char ch=i;
            v.eb(mp[i],ch);
        }
    }

    ll ans=0;
    sort(vll(v));

    if(v.size()==1)
        cout<<n<<endl;

    else
    {
        ll res=v[0].F;

        for(j=0; j<v.size(); j++)
        {

            for(p=j+1; p<v.size(); p++)
            {
                a=p;
                b=j;

                ans=0;
                char aa=v[a].S,bb=v[b].S;

                ll cnt2=v[b].F;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {
//cout<<aa<<" "<<str[i]<<endl;
                        ans+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                swap(v[a],v[b]);

                aa=v[a].S,bb=v[b].S;

              cnt2=v[b].F;

                sum=0;

                for(i=0; i<n; i++)
                {
                    if(str[i]==aa)
                    {

                        sum+=(cnt2);
                    }
                    else if(str[i]==bb)
                        cnt2--;
                }

                ans=max3(sum,ans,v[b].F);

                ans=max(ans,v[a].F);

                res=max(res,ans);

                  swap(v[a],v[b]);
            }
        }

        cout<<res<<endl;

    }

}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;
ll dp[N],Cnt[30],f[30],last[30];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    //for(int i=0;i<26;i++)f[i]=-1;
    dp[1]=1;
    Cnt[s[1]-'a']++;
    f[s[1]-'a']=1;
    last[s[1]-'a']=1;
    for(int i=2;i<=n;i++){
        dp[i]=max(dp[i-1],last[s[i]-'a']+f[s[i]-'a']);
        if(dp[i-1]>last[s[i]-'a']+f[s[i]-'a']){
            f[s[i]-'a']=dp[i-1];
        }
        last[s[i]-'a']=dp[i];
    }
    cout<<dp[n]<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;
ll dp[N],Cnt[30],f[30],last[30];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    //for(int i=0;i<26;i++)f[i]=-1;
    dp[1]=1;
    Cnt[s[1]-'a']++;
    f[s[1]-'a']=1;
    last[s[1]-'a']=1;
    for(int i=2;i<=n;i++){
        dp[i]=max(dp[i-1],dp[i-1]+f[s[i]-'a']);
        if(dp[i-1]>=last[s[i]-'a']+f[s[i]-'a']){
            f[s[i]-'a']=dp[i-1];
        }
        last[s[i]-'a']=dp[i];
    }
    cout<<dp[n]<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;
ll dp[N],Cnt[30],f[30],last[30];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    //for(int i=0;i<26;i++)f[i]=-1;
    dp[1]=1;
    Cnt[s[1]-'a']++;
    f[s[1]-'a']=1;
    last[s[1]-'a']=1;
    for(int i=2;i<=n;i++){
        dp[i]=max(dp[i-1],last[s[i]-'a']+f[s[i]-'a']);
        if(dp[i-1]>=last[s[i]-'a']+f[s[i]-'a']){
            f[s[i]-'a']=dp[i-1];
        }
        last[s[i]-'a']=dp[i];
    }
    cout<<dp[n]<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;

vector<ll> v;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    ll Ans=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            if(j==i)C;
            ll Cnt=0,c=0;
            for(int k=1;k<=n;k++){
                if(s[k]-'a'==i)c++;
                else if(s[k]-'a'==j)Cnt+=c;
            }
            v.pb(Cnt);
            Max(Ans,c);
        }
    }
    sort(v.begin(),v.end());
    ll Cnt=0;
    for(int i=v.size()-1;i>=0;i--){
        if(i<v.size()-1){
            if(v[i]==v[i+1])Cnt+=v[i];
            else B;
        }
        else Cnt=v[i];
    }
    Max(Ans,Cnt);

    cout<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    ll Ans=0,cc=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            if(i==j)C;
            ll Cnt=0,c=0;
            for(int k=1;k<=n;k++){
                if(s[k]-'a'==i)c++;
                if(s[k]-'a'==j)Cnt+=c;
            }
            Max(Ans,Cnt);
            Max(Ans,(c*c-c)/2);
        }
    }

    cout<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    ll Ans=0,cc=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            if(i==j)C;
            ll Cnt=0,c=0;
            for(int k=1;k<=n;k++){
                if(s[k]-'a'==i)c++;
                if(s[k]-'a'==j)Cnt+=c;
            }
            Max(Ans,Cnt);
            Max(Ans,c);
            Max(Ans,(c*c-c)/2);
        }
    }

    cout<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    ll Ans=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            if(j==i)C;
            ll Cnt=0,c=0;
            for(int k=1;k<=n;k++){
                if(s[k]-'a'==i)c++;
                else if(s[k]-'a'==j)Cnt+=c;
            }
            Max(Ans,Cnt);
            Max(Ans,c);
        }
    }

    cout<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
//#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll Mod=1e9+7 ;
ll poww(ll a,ll b,ll mod){
    ll res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

void Max(ll& x,ll y){
x=max(x,y);
}
void Min(ll& x,ll y){
x=min(x,y);
}

const ll N=300300,K=30,Inf=1e17;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    int n=s.size();
    s="*"+s+"**";
    ll Ans=0,cc=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            ll Cnt=0,c=0;
            for(int k=1;k<=n;k++){
                if(s[k]-'a'==i)c++;
                if(s[k]-'a'==j)Cnt+=c;
            }
            Max(Ans,Cnt);
            Max(Ans,c);
        }
    }

    cout<<Ans<<'\n';

    return 0;
}


#include <iostream>
#include<cstdlib>

using namespace std;

string s ,op[100];
int c=0;

void try_(int i,string cu)
{  string temp;
    if(i==s.length())
    { op[c]=cu;
    c++;
      return;

    }
       temp=cu;
       cu+=s[i];
       try_(i+1,cu);
       cu=temp;
       try_(i+1,cu);

}
int main()
{ cin>>s;
int i;
  try_(0,"");
  int p[100];
  for(i=0;i<c;i++)
    p[i]=0;
  for(int j=0 ;j< c; j++)
  {
   string k;
  k=op[j];
  for(i=0;i<c;i++)
  if(op[i]==k)
    p[j]++;
}
int max_=p[0];
for(i=0;i<c;i++)
{
    if(p[i]>max_)
        max_=p[i];
}
cout<<max_<<endl;

/*for(i=0;i<c;i++)
{
    cout<<op[i]<<"   "<<p[i]<<endl;
}*/
}


#include <iostream>
#include<cstdlib>

using namespace std;

string s ,op[1000000];
int c=0;

void try_(int i,string cu)
{  string temp;
    if(i==s.length())
    { op[c]=cu;
    c++;
      return;

    }
       temp=cu;
       cu+=s[i];
       try_(i+1,cu);
       cu=temp;
       try_(i+1,cu);

}
int main()
{ cin>>s;
int i;
  try_(0,"");
  int max_=0;
  for(int j=0 ;j< c; j++)
  { int m=0;
   string k;
  k=op[j];
  for(i=0;i<c;i++)
  if(op[i]==k)
    m++;
    if(m>max_)
        max_=m;
}

cout<<max_<<endl;

/*for(i=0;i<c;i++)
{
    cout<<op[i]<<"   "<<p[i]<<endl;
}*/
}


#include<bits/stdc++.h>
using namespace std;
long long int dp[26][26],a[26];

int main()
{
    string s;
    char index;
    map<char, int > a;
   long long  int i, j, sum,c,sol;
    cin>>s;
    for(i=0; i<s.length(); i++)
    {     c=s[i]-'a';
        for(j=0; j<26; j++)
        {
            index=j+'a';
            dp[j][c]+=a[index];
        }
        a[s[i]]++;

    }
    map<char, int > ::iterator ptr=a.begin();
    sol=ptr->second;
    for(ptr=a.begin(); ptr!=a.end(); ptr++)
    {
        if(sol<ptr->second)
            sol=ptr->second;
    }
    for (int i=0; i<26; i++)
        for (int j=0; j<26; j++)
            sol=max(sol,dp[i][j]);
    cout<<sol<<endl;

}


#include <iostream>
#include<cstdlib>

using namespace std;

string s ,op[1000000];
int c=0;

void try_(int i,string cu)
{  string temp;
    if(i==s.length())
    { op[c]=cu;
    c++;
      return;

    }
       temp=cu;
       cu+=s[i];
       try_(i+1,cu);
       cu=temp;
       try_(i+1,cu);

}
int main()
{ cin>>s;
int i;
  try_(0,"");
  int max_;
  for(int j=0 ;j< c; j++)
  { int m=0;
   string k;
  k=op[j];
  for(i=0;i<c;i++)
  if(op[i]==k)
    m++;
    if(m>max_)
        max_=m;
}

cout<<max_<<endl;

/*for(i=0;i<c;i++)
{
    cout<<op[i]<<"   "<<p[i]<<endl;
}*/
}


#include <iostream>
#include<cstdlib>

using namespace std;

string s ,op[100000];
int c=0;

void try_(int i,string cu)
{  string temp;
    if(i==s.length())
    { op[c]=cu;
    c++;
      return;

    }
       temp=cu;
       cu+=s[i];
       try_(i+1,cu);
       cu=temp;
       try_(i+1,cu);

}
int main()
{ cin>>s;
int i;
  try_(0,"");
  int max_;
  for(int j=0 ;j< c; j++)
  { int m=0;
   string k;
  k=op[j];
  for(i=0;i<c;i++)
  if(op[i]==k)
    m++;
    if(m>max_)
        max_=m;
}

cout<<max_<<endl;

/*for(i=0;i<c;i++)
{
    cout<<op[i]<<"   "<<p[i]<<endl;
}*/
}


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

string s ;
vector<string> op;
int c=0;

void try_(int i,string cu)
{  string temp;
    if(i==s.length())
    { op.push_back(cu);
    c++;
      return;

    }
       temp=cu;
       cu+=s[i];
       try_(i+1,cu);
       cu=temp;
       try_(i+1,cu);

}
int main()
{ cin>>s;
int i;
  try_(0,"");
  int max_=0;
  for(int j=0 ;j< c; j++)
  { int m=0;
   string k;
  k=op[j];
  for(i=0;i<c;i++)
  if(op[i]==k)
    m++;
    if(m>max_)
        max_=m;
}

cout<<max_<<endl;

/*for(i=0;i<c;i++)
{
    cout<<op[i]<<"   "<<p[i]<<endl;
}*/
}


#include<bits/stdc++.h>
using namespace std;
int dp[26][26],a[26];

int main()
{
    string s;
    char index;
    map<char, int > a;
    int i, j, sum,c,sol;
    cin>>s;
    for(i=0; i<s.length(); i++)
    {     c=s[i]-'a';
        for(j=0; j<26; j++)
        {
            index=j+'a';
            dp[j][c]+=a[index];
        }
        a[s[i]]++;

    }
    map<char, int > ::iterator ptr=a.begin();
    sol=ptr->second;
    for(ptr=a.begin(); ptr!=a.end(); ptr++)
    {
        if(sol<ptr->second)
            sol=ptr->second;
    }
    for (int i=0; i<26; i++)
        for (int j=0; j<26; j++)
            sol=max(sol,dp[i][j]);
    cout<<sol<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    cin >>s;
    long long    n=  s.size(),cnt[26];
    long long dp[26][n],ans=0;
    for(int i=0; i<26; i++)
        for(int j=0; j<n; j++)
            dp[i][j]=0;
    for(int i=0; i<26; i++)
        cnt[i]=0;
    for(  auto  x : s )
    {
        int i = x-'a';
        for(int j=0; j<26; j++)
        {
            dp[j][i] +=cnt[j];
        }
        cnt[i]++;
    }
    for(int i=0; i<26; i++)
    {
        for(int j=0; j<n; j++)
        {
            ans= max(ans,dp[i][j]);
        }
    }
    cout <<ans <<endl;

}


#include<bits/stdc++.h>
using namespace std;
const int N=26;
set< int > fre[26];
      int dp[26];
int main()
{

      string s;
      cin >>s;

      for(int i=0;i<s.size();i++)
      {
          dp[ s[i]-'a']++;
      }

      int ans=1;
     for(int i=0;i<26;i++)
     {
         if(dp[i])
         {
             ans*=dp[i];
         }
     }
    cout <<ans <<endl;
}


#include<bits/stdc++.h>
using namespace std;
long long dp[26][26],cnt[26],ans;
int main()
{

    string s;
    cin >>s;
    long long    n=  s.size();
    for(  auto  x : s )
    {
        int i = x-'a';
        for(int j=0; j<26; j++)
        {

            dp[j][i] +=cnt[j];
            ans=max(ans,dp[j][i]);
        }
        cnt[i]++;

        ans=max(ans,cnt[i]);

    }

    cout <<ans <<endl;

}


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

      long long dp[26];
  main()
{

      string s;
      cin >>s;

      for(long long i=0;i<s.size();i++)
      {
          dp[ s[i]-'a']++;
      }

      long long ans=1;
     for(long long i=0;i<26;i++)
     {
         if(dp[i])
         {
             ans*=dp[i];
         }
     }
    cout <<ans <<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    cin >>s;
    long long    n=  s.size(),cnt[26];
    long long dp[26][26],ans=0;

    for(int i=0; i<26; i++)
        for(int j=0; j<26; j++)
            dp[i][j]=0;

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

    for(  auto  x : s )
    {
        int i = x-'a';
        for(int j=0; j<26; j++)
        {
            dp[j][i] +=cnt[j];
        }
        cnt[i]++;
    }
    for(int i=0; i<26; i++)

        for(int j=0; j<26; j++)

            ans= max(ans,dp[i][j]);

    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;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;
}