#include <bits/stdc++.h>
using namespace std;
void err() { cout << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) {
  for (auto x : a) cout << x << ' ';
  err(args...);
}
template <typename T, typename... Args>
void err(T a, Args... args) {
  cout << a << ' ';
  err(args...);
}
string s;
int dp[1 << 20];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    int used = 0;
    for (int j = i; j < n && j - i < 20; ++j) {
      int c = s[j] - 'a';
      if ((used >> c) & 1) break;
      used |= 1 << c;
      dp[used] = j - i + 1;
    }
  }
  for (int i = 1; i < 1 << 20; ++i) {
    for (int j = 0; j < 20; ++j) {
      if (!((i >> j) & 1)) {
        dp[i | 1 << j] = max(dp[i | 1 << j], dp[i]);
      }
    }
  }
  int S = 1 << 20, ans = dp[S - 1];
  for (int i = 1; i < 1 << 20; ++i) {
    int mask = i ^ (S - 1);
    ans = max(ans, dp[i] + dp[mask]);
  }
  cout << ans << '\n';
  return 0;
}
