#include <bits/stdc++.h>
using namespace std;
namespace Solve {
const int MAXS = 1100000;
inline int mymax(int a, int b) { return a > b ? a : b; }
int F[MAXS];
char s[MAXS];
void work() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    int S0 = 0;
    for (int k = 1; k <= 20; k++) {
      if (i + k - 1 >= n) break;
      if (S0 & (1 << (s[i + k - 1] - 'a'))) break;
      S0 |= 1 << (s[i + k - 1] - 'a');
      F[S0] = k;
    }
  }
  for (int S = 0; S < (1 << 20); S++)
    for (int k = 0; k < 20; k++) F[S | 1 << k] = mymax(F[S | 1 << k], F[S]);
  int ans = F[0] + F[(1 << 20) - 1];
  for (int S = 1; S < (1 << 20); S++)
    ans = mymax(ans, F[S] + F[~S & ((1 << 20) - 1)]);
  printf("%d\n", ans);
  return;
}
}  // namespace Solve
int main() {
  Solve::work();
  return 0;
}
