#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
const int N = 1 << 21;
int ct[N];
bool mark[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    int mask = 0;
    for (int j = i; j >= 0; --j) {
      int x = s[j] - 'a';
      x = (1 << x);
      if (mask & x) break;
      mask |= x;
      ct[mask] = __builtin_popcount(mask);
      mark[mask] = 1;
    }
  }
  for (int mask = 0; mask < (1 << 20); ++mask) {
    for (int bit = 0; bit < 20; ++bit) {
      if ((mask ^ (1 << bit)) < mask)
        ct[mask] = max(ct[mask], ct[mask ^ (1 << bit)]);
    }
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << 20); ++mask)
    if (mark[mask]) ans = max(ans, ct[mask] + ct[mask ^ ((1 << 20) - 1)]);
  cout << ans;
}
