#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1 << 20;
int f[N], g[N];
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> pre(20, -1);
  for (int i = 0, j = 0; i < n; ++i) {
    j = max(j, pre[s[i] - 'a'] + 1);
    pre[s[i] - 'a'] = i;
    int mask = 0;
    for (int k = i; k >= j; --k) {
      mask |= 1 << (s[k] - 'a');
      f[mask] = 1;
    }
  }
  for (int mask = 1; mask < N; ++mask) {
    if (f[mask]) {
      g[mask] = __builtin_popcount(mask);
    }
    for (int i = 0; i < 20; ++i) {
      int nmask = mask | 1 << i;
      if (nmask == mask) continue;
      g[nmask] = max(g[nmask], g[mask]);
    }
  }
  int ans = 0;
  for (int mask = 1; mask < N; ++mask) {
    if (!f[mask]) continue;
    ans = max(ans, __builtin_popcount(mask) + g[(N - 1) ^ mask]);
  }
  cout << ans << endl;
}
