#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, M = (1 << 20);
int f[M], a[N];
char lx[N];
int main() {
  scanf("%s", lx + 1);
  int n = strlen(lx + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = lx[i] - 'a';
  }
  for (int i = 1; i <= n; ++i) {
    int j = i, pos = 0;
    for (; j <= n; ++j) {
      if ((pos >> a[j]) & 1) break;
      pos |= (1 << a[j]);
      f[pos] = max(f[pos], j - i + 1);
    }
  }
  for (int i = 0; i < 20; ++i)
    for (int j = 0; j < M; ++j) {
      if ((j >> i) & 1) {
        f[j] = max(f[j], f[j ^ (1 << i)]);
      }
    }
  int ans = 0;
  for (int i = 0; i < M; ++i) ans = max(ans, f[i] + f[(M - 1) ^ i]);
  printf("%d\n", ans);
  return 0;
}
