#include <bits/stdc++.h>
using namespace std;
using ll = long long;
char s[1000005];
int n, f[1 << 20];
bool f1[25];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    memset(f1, 0, sizeof(f1));
    int tot = 0, x = 0;
    for (int j = 0; j + i <= n; j++) {
      if (f1[s[i + j] - 'a']) break;
      f1[s[i + j] - 'a'] = 1;
      tot++;
      x += (1 << (s[i + j] - 'a'));
      f[x] = max(f[x], tot);
    }
  }
  for (int i = 0; i < (1 << 20); i++)
    for (int j = 1; j <= 20; j++)
      if ((1 << (j - 1)) & i) f[i] = max(f[i], f[i ^ (1 << (j - 1))]);
  int ans = 0;
  for (int i = 0; i < (1 << 20); i++)
    ans = max(ans, f[i] + f[((1 << 20) - 1) ^ i]);
  printf("%d", ans);
  return 0;
}
