#include <bits/stdc++.h>
using namespace std;
int n, f[2000005];
char a[2000005];
int main() {
  cin >> a;
  n = strlen(a);
  int mask = 0, j = 0;
  for (int i = 0; i < n; i++) {
    int mask = 0;
    for (int j = i; j < i + 20 && j < n; j++) {
      if (mask & (1 << (a[j] - 'a'))) break;
      mask |= 1 << (a[j] - 'a');
      f[mask] = __builtin_popcount(mask);
    }
  }
  for (int i = 0; i < (1 << 20); i++)
    for (int j = i; j; j ^= ((j) & (-(j))))
      f[i] = max(f[i], f[i ^ ((j) & (-(j)))]);
  int ans = 0;
  for (int i = 0; i < (1 << 20); i++)
    ans = max(ans, f[i] + f[((1 << 20) - 1) ^ i]);
  cout << ans << endl;
  return 0;
}
