#include <bits/stdc++.h>
using namespace std;
int const N = 20;
bool is[(1 << N) + 20];
int dp[(1 << N) + 20];
int main() {
  clock_t begin = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    int mask = 0;
    for (int j = i; j < n; j++) {
      int t = s[j] - 'a';
      if (mask & (1 << t)) break;
      mask |= (1 << t);
      is[mask] = 1;
    }
  }
  for (int i = 0; i < (1 << N); i++)
    if (is[i]) dp[i] = __builtin_popcount(i);
  int ans = 0;
  for (int mask = 0; mask < (1 << N); mask++) {
    int cur = __builtin_popcount(mask);
    for (int t = 0; t < N; t++) {
      if (mask & (1 << t)) {
        dp[mask] = max(dp[mask], dp[mask ^ (1 << t)]);
      }
    }
  }
  for (int i = 0; i < (1 << N); i++) {
    if (is[i]) {
      ans = max(ans, dp[i ^ ((1 << N) - 1)] + __builtin_popcount(i));
    }
  }
  cout << ans << endl;
  return 0;
}
