#include <bits/stdc++.h>
using namespace std;
int n, ans, dp[1 << 20];
char s[1000010];
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++)
    for (int j = i, m = 0; j < n; j++) {
      if (m & 1 << (s[j] - 'a')) break;
      dp[m] = max(dp[m |= 1 << (s[j] - 'a')], j - i + 1);
    }
  for (int m = 0; m < 1 << 20; m++)
    for (int j = 0; j < 20; j++)
      if (m & 1 << j) dp[m] = max(dp[m], dp[m ^ 1 << j]);
  for (int m = 0; m < 1 << 20; m++)
    ans = max(ans, dp[m] + dp[~m & (1 << 20) - 1]);
  printf("%d", ans);
}
