#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 21;
int dp1[1 << MAX_N], dp2[1 << MAX_N], N;
string S;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> S;
  N = (int)S.size();
  for (int i = 0; i < N; i++) {
    int Mask = 0;
    for (int j = i; j < N; j++) {
      int now = S[j] - 'a';
      if (Mask & (1 << now)) break;
      dp1[Mask | (1 << now)] = max(dp1[Mask | (1 << now)], j - i + 1);
      Mask |= (1 << now);
    }
  }
  for (int Mask = 0; Mask < (1 << MAX_N); Mask++) dp2[Mask] = dp1[Mask];
  for (int Mask = 0; Mask < (1 << MAX_N); Mask++)
    for (int i = 0; i < MAX_N; i++)
      if (Mask & (1 << i)) dp2[Mask] = max(dp2[Mask], dp2[Mask ^ (1 << i)]);
  int ans = 1;
  for (int Mask = 0; Mask < (1 << MAX_N); Mask++)
    ans = max(ans, dp1[Mask] + dp2[((1 << MAX_N) - 1) ^ Mask]);
  cout << ans << endl;
  return 0;
}
