#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
const long long Alpha = 20;
string s;
bool X[1ll << Alpha];
long long len[1ll << Alpha];
long long y[Alpha + 1];
int main() {
  y[0] = 1;
  for (long long b = 1; b <= Alpha; b++) {
    y[b] = y[b - 1] << 1;
  }
  cin >> s;
  long long n = s.length();
  X[0] = true;
  for (long long i = 0; i <= n - 1; i++) {
    long long x = 0, b;
    long long j = i;
    while ((j < n) && ((x & y[b = (s[j] - 'a')]) == 0)) {
      x |= y[b];
      X[x] = true;
      j++;
    }
  }
  for (long long x = 0; x <= y[Alpha] - 1; x++) {
    if (X[x]) {
      for (long long b = 0; b <= Alpha - 1; b++) {
        if ((x & y[b]) > 0) {
          len[x]++;
        }
      }
      continue;
    }
    for (long long b = 0; b <= Alpha - 1; b++) {
      if ((x & y[b]) == 0) {
        continue;
      }
      len[x] = max(len[x], len[x ^ y[b]]);
    }
  }
  long long ff = y[Alpha] - 1;
  long long ans = 0;
  for (long long x = 0; x <= y[Alpha] - 1; x++) {
    ans = max(ans, len[x] + len[ff ^ x]);
  }
  cout << ans << endl;
}
