#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  string a;
  cin >> a;
  int n = signed(a.size());
  int dp[(1 << 20) + 1] = {};
  for (int i = 0; i < n; i++) {
    int ret[20] = {};
    int mask = 0;
    for (int j = 0; i + j < n; j++) {
      if (ret[a[i + j] - 'a']) break;
      ret[a[i + j] - 'a']++;
      mask |= (1 << (a[i + j] - 'a'));
      dp[mask] = __builtin_popcount(mask);
    }
  }
  for (int i = 0; i < (1 << 20); i++) {
    for (int j = 0; j < 20; j++) {
      if ((i | (1 << j)) == i) {
        dp[i] = max(dp[i], dp[i ^ (1 << j)]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 20); i++) {
    if (dp[i] == __builtin_popcount(i)) {
      int val = ((i) ^ ((1 << 20) - 1));
      ans = max(ans, dp[i] + dp[val]);
    }
  }
  cout << ans;
}
