#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> dp(1 << 20);
  for (int i = 0; i < s.size(); ++i) {
    int current = 0;
    for (int j = 0; i + j < s.size(); ++j) {
      if ((current >> (s[i + j] - 'a')) & 1) break;
      current |= (1 << (s[i + j] - 'a'));
      dp[current] = __builtin_popcount(current);
    }
  }
  for (int i = 0; i < (1 << 20); ++i) {
    for (int j = 0; j < 20; ++j) {
      if ((i >> j) & 1) {
        dp[i] = max(dp[i], dp[i ^ (1 << j)]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i < (1 << 20); ++i) {
    res = max(res, dp[i] + dp[~i & ((1 << 20) - 1)]);
  }
  cout << res << endl;
}
