#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = (int)s.length();
  const int NMX = 1 << 20;
  vector<int> dp(NMX, 0);
  for (int i = 0; i < n; i++) {
    int cur = 0;
    for (int j = i; j < min(n, i + 20); j++) {
      int c = int(s[j] - 'a');
      if (cur & (1 << c)) break;
      cur |= 1 << c;
      dp[cur] = __builtin_popcount(cur);
    }
  }
  for (int i = 0; i < NMX; i++) {
    for (int j = 0; j < 20; j++) {
      if (i & (1 << j)) dp[i] = max(dp[i], dp[i ^ (1 << j)]);
    }
  }
  int ans = 0;
  for (int i = 0; i < NMX; i++) {
    int comp = ~i & (NMX - 1);
    ans = max(ans, dp[i] + dp[comp]);
  }
  cout << ans;
  return 0;
}
