#include <bits/stdc++.h>
using namespace std;
const int N = 20;
bool haveMask[1 << N];
int dp[1 << N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) s[i] -= 'a';
  vector<bool> have;
  for (int i = 0; i < s.size(); i++) {
    have.assign(N, false);
    int mask = 0;
    for (int j = i; j < s.size() && !have[s[j]]; j++) {
      have[s[j]] = true;
      mask += 1 << s[j];
      haveMask[mask] = true;
    }
  }
  for (int mask = 0; mask < (1 << N); mask++)
    if (haveMask[mask]) dp[mask] = __builtin_popcount(mask);
  for (int i = 0; i < N; i++)
    for (int mask = 0; mask < (1 << N); mask++)
      if (mask >> i & 1) dp[mask] = max(dp[mask], dp[mask - (1 << i)]);
  int ans = 0;
  for (int mask = 0; mask < (1 << N); mask++)
    if (haveMask[mask])
      ans = max(ans, __builtin_popcount(mask) + dp[mask ^ ((1 << N) - 1)]);
  cout << ans << endl;
  return 0;
}
