#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const int N = 1 << 20;
int dp[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(25);
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    int msk = 0;
    for (int j = i; j < n; j++) {
      int c = s[j] - 'a';
      if (msk & (1 << c)) break;
      msk |= 1 << c;
      dp[msk] = j - i + 1;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 20; j++) {
      if (i & (1 << j)) dp[i] = max(dp[i], dp[i ^ (1 << j)]);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, dp[i] + dp[N - i - 1]);
  }
  cout << ans;
}
