#include <bits/stdc++.h>
using namespace std;
const int K = (20);
int F[1 << K];
int A[1 << K];
void sosdp() {
  for (long long mask = 0, to = 1 << K; mask < to; mask++) {
    F[mask] = A[mask];
  }
  for (long long i = 0, to = K; i < to; i++)
    for (long long mask = 0, to = 1 << K; mask < to; mask++) {
      if (mask & (1 << i)) F[mask] = max(F[mask], F[mask ^ (1 << i)]);
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  string s;
  cin >> s;
  for (long long i = 0, to = (int)s.size(); i < to; i++) {
    int mask = 0;
    for (long long j = 0, to = K; j < to; j++) {
      if (i + j >= (int)s.size()) break;
      int value = s[i + j] - 'a';
      if (mask & (1 << value)) break;
      mask |= (1 << value);
      A[mask] = __builtin_popcount(mask);
    }
  }
  sosdp();
  int ans = 0;
  for (long long i = 0, to = 1 << K; i < to; i++) {
    ans = max(ans, A[i] + F[(1 << K) - i - 1]);
  }
  cout << ans << endl;
  return 0;
}
