from sys import exit

def iis(): return map(int, input().split())
def ii(): return int(input())
def liis():	return list(map(int, input().split()))

s = input()

todos = {}
for i in range(len(s)):
	if s[i] not in todos:
		todos[s[i]] = 0
	todos[s[i]] += 1

ans = 1
maxi1 = 1
maxi2 = 1
maxi1c = s[0]
for k in todos:
	if todos[k] > maxi1:
		maxi1 = todos[k]
		maxi1c = k

def ans(s, c, d, n):
	at = 0
	ret = 0
	for i in s:
		if i == d:
			ret += at
		if i == c:
			at += 1
	return ret

a = []
answ = 0
for i in todos:
	a.append([todos[i], i])
	answ = max(answ, todos[i])

for i in range(len(a)):
	for j in range(len(a)):
		answ = max(answ, ans(s, a[i][1], a[j][1], a[j][0]))
print(answ)
