#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000009;
const int INF = 2e9;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(char ch) {
  string s;
  s += ch;
  return s;
}
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
void solve() {
  const int maxN = ((1 << 20) + 10);
  string s;
  cin >> s;
  int n = s.length();
  vector<vector<int> > dp(maxN, vector<int>(21));
  vector<int> dpminus1(maxN);
  for (int len = 1; len <= 20; len++) {
    for (int i = 0; i + len - 1 <= n - 1; i++) {
      int mask = 0;
      vector<bool> used(20);
      for (int j = i; j <= i + len - 1; j++) {
        if (used[s[j] - 'a']) {
          break;
        } else {
          used[s[j] - 'a'] = 1;
        }
        mask |= (1 << (s[j] - 'a'));
      }
      dpminus1[mask] = __builtin_popcount(mask);
    }
  }
  for (int i = 0; i <= 19; i++) {
    for (int mask = 0; mask < (1 << 20); mask++) {
      if (mask & (1 << i)) {
        dp[mask][i] = max(
            (i >= 1 ? dp[mask][i - 1] : dpminus1[mask]),
            (i >= 1 ? dp[mask ^ (1 << i)][i - 1] : dpminus1[mask ^ (1 << i)]));
      } else {
        dp[mask][i] = (i >= 1 ? dp[mask][i - 1] : dpminus1[mask]);
      }
    }
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << 20); mask++) {
    if (dpminus1[mask]) {
      int comp = ~mask & ((1 << 20) - 1);
      ans = max(ans, dp[comp][19] + dpminus1[mask]);
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
