#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int M = 1 << 20;
int n, a[N], g[M];
char s[N];
bool f[M];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = s[i] - 'a';
    for (int j = 0, val = 0; j < 20; ++j) {
      if (i - j <= 0 || (val & 1 << a[i - j])) break;
      val |= 1 << a[i - j];
      f[val] = 1;
    }
  }
  for (int i = 0; i < M; ++i) {
    int c = 0;
    for (int j = 0; j < 20; ++j)
      if (i & 1 << j) g[i] = max(g[i], g[i ^ 1 << j]), c++;
    if (f[i]) g[i] = c;
  }
  int ans = 0;
  for (int i = 0; i < M; ++i)
    if (f[i]) {
      ans = max(ans, g[i] + g[(M - 1) ^ i]);
    }
  printf("%d\n", ans);
}
