#include <bits/stdc++.h>
using namespace std;
int n;
char str[1000001];
int cnt[1 << 20];
bool is_used[20];
int f[1 << 20];
int ans = INT_MIN;
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 0; i ^ 1 << 20; i++) {
    cnt[i] = __builtin_popcount(i);
  }
  for (int i = 1; i <= n; i++) {
    fill(is_used, is_used + 20, false);
    int x = 0;
    for (int j = i; j - i + 1 <= 20 && j <= n; j++) {
      if (is_used[str[j] - 'a']) {
        break;
      }
      is_used[str[j] - 'a'] = true;
      x |= 1 << (str[j] - 'a');
      f[x] = cnt[x];
    }
  }
  for (int i = 1; i ^ 1 << 20; i++) {
    for (int j = 0; j ^ 20; j++) {
      if (i & (1 << j)) {
        f[i] = max(f[i], f[i ^ (1 << j)]);
      }
    }
  }
  for (int i = 0; i ^ 1 << 20; i++) {
    ans = max(ans, f[i] + f[((1 << 20) - 1) ^ i]);
  }
  printf("%d\n", ans);
  return 0;
}
