#include <bits/stdc++.h>
using namespace std;
string str, str2;
int n, dp[(1 << 20) + 100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> str2;
  str = "$" + str2;
  n = str2.length();
  for (int i = 1; i <= n; i++) {
    int bitmask = 0;
    int freq[21];
    memset(freq, 0, sizeof(freq));
    for (int j = i; j >= max(1, i - 19); j--) {
      if (freq[str[j] - 'a']) break;
      freq[str[j] - 'a'] = 1;
      bitmask += (1 << (str[j] - 'a'));
      dp[bitmask] = __builtin_popcount(bitmask);
    }
  }
  for (int i = 0; i < (1 << 20); i++) {
    for (int j = 0; j < 20; j++) {
      if (i & (1 << j)) {
        dp[i] = max(dp[i], dp[i ^ (1 << j)]);
      }
    }
  }
  int finalAns = 0;
  for (int i = 1; i <= n; i++) {
    int bitmask = 0;
    int freq[21];
    memset(freq, 0, sizeof(freq));
    for (int j = i; j >= max(1, i - 19); j--) {
      if (freq[str[j] - 'a']) break;
      freq[str[j] - 'a'] = 1;
      bitmask += (1 << (str[j] - 'a'));
      finalAns = max(finalAns, __builtin_popcount(bitmask) +
                                   dp[((1 << 20) - 1) ^ bitmask]);
      if (finalAns == 20) break;
    }
  }
  cout << finalAns << "\n";
}
