#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000005;
const int maxm = maxn * 2;
const int inf = 0x3f3f3f3f;
const int mod = 10007;
char s[1000000];
int dp[1 << 20], ans;
int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    int mask = 0;
    for (int j = i; j < min(n, i + 20); j++) {
      if ((1 << (s[j] - 'a')) & mask) break;
      mask |= (1 << (s[j] - 'a'));
      dp[mask] = j - i + 1;
    }
  }
  for (int i = 1; i < (1 << 20); i++) {
    for (int j = 0; j < 20; j++) {
      if (!(i & (1 << j))) dp[i ^ (1 << j)] = max(dp[i], dp[i ^ (1 << j)]);
    }
  }
  for (int i = 0; i < (1 << 20); i++)
    ans = max(ans, dp[i] + dp[((1 << 20) - 1) ^ i]);
  printf("%d\n", ans);
}
