#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
const int N = 1000005, M = 20, MOD = 1e9 + 7;
int n, mx[1 << M], ct[1 << M];
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.length();
  for (int i = 1; i < (1 << M); ++i) {
    ct[i] = ct[i ^ (i & -i)] + 1;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i, ms = 0; j < n && j - i < 20; ++j) {
      if ((ms >> (s[j] - 'a')) & 1) {
        break;
      }
      ms ^= 1 << (s[j] - 'a');
      mx[ms] = max(mx[ms], ct[ms]);
    }
  }
  for (int j = 0; j < M; ++j) {
    for (int i = 1; i < (1 << M); ++i) {
      if ((i >> j) & 1) {
        mx[i] = max(mx[i], mx[i ^ (1 << j)]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << M); ++i) {
    ans = max(ans, mx[i] + mx[((1 << M) - 1) ^ i]);
  }
  cout << ans << '\n';
  return 0;
}
