#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
char s[N], cnt[30];
int dp[N], ans[N], n, m, i, j, c, x;
int main() {
  for (scanf("%s", s + 1), n = strlen(s + 1), i = 1; i <= n; ++i)
    for (memset(cnt, 0, sizeof(cnt)), x = 0, j = i;
         j <= n && !cnt[c = s[j] - 'a']; ++j)
      x |= 1 << c, ans[x] = dp[x] = j - i + 1, cnt[c]++;
  for (i = 0; i <= 19; ++i)
    for (j = 0; j < N; ++j)
      if (j >> i & 1) dp[j] = max(dp[j], dp[j ^ (1 << i)]);
  for (i = x = 0; i < N; ++i) x = max(x, ans[i] + dp[N - 1 ^ i]);
  printf("%d\n", x);
}
