#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int dp[(1 << N) - 1] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  string str;
  cin >> str;
  int L = str.length();
  int val = 1;
  int mask;
  int c;
  for (int i = 0; i < L; i++) {
    mask = 0;
    for (int k = 0; k <= N && i + k < L; k++) {
      c = str[i + k] - 'a';
      if ((mask & (1 << c))) break;
      mask = mask | (1 << c);
      dp[mask] = k + 1;
    }
  }
  for (int i = 0; i < (1 << N); i++)
    for (int j = 0; j < N; j++)
      if (i & (1 << j)) dp[i] = max(dp[i], dp[i ^ (1 << j)]);
  for (int i = 0; i < (1 << N); i++)
    val = max(val, dp[i] + dp[(~i) & ((1 << N) - 1)]);
  cout << val << '\n';
  return 0;
}
