#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
const long long mod = 1e9 + 7;
char s[maxn];
int dp[(1 << 21) + 50];
bool ok[(1 << 21) + 50];
int cal(int x) {
  if (x == 0) return 0;
  return x % 2 + cal(x / 2);
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> s + 1;
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    int mark = 0, cnt = 0;
    for (int j = i; j <= n; j++) {
      int k = s[j] - 'a';
      if (mark & (1 << k)) break;
      mark |= (1 << k);
      cnt++;
      ok[mark] = 1;
      dp[mark] = cnt;
    }
  }
  for (int i = 20; i >= 0; i--) {
    for (int j = 0; j < (1 << 20); j++) {
      if ((j & (1 << i)) == 0) {
        dp[j | (1 << i)] = max(dp[j | (1 << i)], dp[j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 20); i++) {
    if (ok[i]) ans = max(ans, cal(i) + dp[((1 << 20) - 1) ^ i]);
  }
  cout << ans << endl;
  return 0;
}
