#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string str;
  cin >> str;
  unordered_set<unsigned int> pattern;
  for (unsigned int i = 0; i < str.length(); i++) {
    unsigned int cur = 0;
    for (int j = 0; j < 20 && i + j < str.length(); j++) {
      unsigned int p = str[i + j] - 'a';
      if (!((cur >> p) & 1)) {
        cur |= 1 << p;
        pattern.emplace(cur);
      } else {
        break;
      }
    }
  }
  unsigned int ans = 0;
  vector<unsigned int> f(1 << 20);
  for (unsigned int i = 0; i < (1 << 20); i++) {
    if (pattern.count(i)) {
      f[i] = __builtin_popcount(i);
    }
    for (int j = 0; j < 20; j++) {
      unsigned int sub = i ^ (1 << j);
      f[i] = max(f[i], f[sub]);
    }
  }
  for (auto e : pattern) {
    ans = max(ans, __builtin_popcount(e) + f[~e & 0xFFFFF]);
  }
  cout << ans << endl;
  return 0;
}
