#include <bits/stdc++.h>
using namespace std;
int n;
int dp[1 << 20];
char s[1000005];
int len;
int a[1000005];
int ans;
int main() {
  scanf("%s", s + 1);
  len = (int)strlen(s + 1);
  for (int i = 1; i <= len; ++i) a[i] = s[i] - 'a';
  for (int i = 1; i <= len; ++i) {
    int msk = 0;
    int pos = i;
    while (true) {
      if (pos > len) break;
      if (msk & (1 << a[pos])) break;
      msk |= (1 << a[pos]);
      dp[msk] = pos - i + 1;
      ++pos;
    }
  }
  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)]);
      }
    }
  }
  for (int i = 0; i < (1 << 20); ++i) {
    int j = ((1 << 20) - 1) ^ i;
    ans = max(ans, dp[i] + dp[j]);
  }
  printf("%d\n", ans);
  return 0;
}
