#include <bits/stdc++.h>
char s[2000000];
int n, dp[2000000], a, m, v;
int main() {
  scanf("%s", &s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    m = 0;
    for (int j = i; j < n; j++) {
      v = 1 << (s[j] - 'a');
      if (m & v) break;
      m |= v;
      dp[m] = j - i + 1;
    }
  }
  for (int i = 0; i < 1 << 20; i++)
    for (int j = 0; j < 20; j++)
      if (i & (1 << j)) dp[i] = std::max(dp[i], dp[i ^ (1 << j)]);
  for (int i = 0; i < 1 << 20; i++)
    a = std::max(a, dp[i] + dp[((1 << 20) - 1) ^ i]);
  std::cout << a;
}
