#include <bits/stdc++.h>
using namespace std;
const long long N = (1 << 20) + 3;
long long dp[N];
int32_t main() {
  string s;
  cin >> s;
  long long n = s.length();
  for (long long i = 0; i < n; i++) {
    long long mask = 0;
    for (long long j = i; j >= 0; j--) {
      if (mask & (1 << (s[j] - 'a'))) break;
      mask |= (1 << (s[j] - 'a'));
      dp[mask] = i - j + 1;
    }
  }
  for (long long bit = 0; bit < 20; bit++)
    for (long long i = 0; i < (1 << 20); i++)
      if ((i & (1 << bit))) dp[i] = max(dp[i ^ (1 << bit)], dp[i]);
  long long ans = 0;
  for (long long i = 0; i < (1 << 20); i++)
    ans = max(ans, dp[i] + dp[i ^ ((1 << 20) - 1)]);
  cout << ans << endl;
  return 0;
}
