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