#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  int N = S.size();
  vector<int> cnt(1 << 20);
  for (int left = 0; left < (int)(N); ++left) {
    int right = left;
    bitset<20> seen;
    while (right < N && !seen[S[right] - 'a']) {
      seen[S[right] - 'a'] = true;
      cnt[seen.to_ullong()] = seen.count();
      right++;
    }
  }
  auto dp = cnt;
  for (int i = 0; i < (int)(20); ++i) {
    for (int mask = 0; mask < (int)(1 << 20); ++mask) {
      if ((mask >> i) & 1) {
        chmax(dp[mask], dp[mask ^ (1 << i)]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(1 << 20); ++i) {
    chmax(ans, cnt[i] + dp[i ^ ((1 << 20) - 1)]);
  }
  cout << ans << '\n';
}
