#include <bits/stdc++.h>
using namespace std;
int n = 1, f[(1 << 20)], cnt[(1 << 20)], ans;
char t[1000006];
bool vis[(1 << 20)];
int main() {
  for (int &i = n; t[i - 1] != EOF; ++i) {
    char ch = getchar();
    while ((ch > 't' || ch < 'a') && ch != EOF) ch = getchar();
    t[i] = ch;
  }
  n -= 2;
  for (int i = 1; i <= n; ++i) {
    int s = 0;
    for (int j = i; j <= n; ++j) {
      if (s & (1 << t[j] - 'a')) break;
      s |= (1 << t[j] - 'a');
      vis[s] = 1;
    }
  }
  for (int s = 1; s < (1 << 20); ++s) cnt[s] = cnt[s - (s & -s)] + 1;
  for (int s = 0; s < (1 << 20); ++s) {
    if (vis[s]) f[s] = cnt[s];
    for (int i = 0; i < 20; ++i) f[s | (1 << i)] = max(f[s | (1 << i)], f[s]);
  }
  for (int s = 0; s < (1 << 20); ++s) {
    if (!vis[s]) continue;
    ans = max(ans, cnt[s] + f[((1 << 20) - 1) ^ s]);
  }
  printf("%d\n", ans);
  return 0;
}
