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