#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (auto &x : s) x -= 'a';
  vector<int> msks(1 << 20);
  for (int x = 0; x < s.length(); x++) {
    int msk = 0;
    int y = x;
    for (; y >= 0; y--) {
      if (msk >> s[y] & 1) break;
      msk |= 1 << s[y];
      msks[msk] = max(msks[msk], x - y + 1);
    }
    msks[msk] = max(msks[msk], x - y);
  }
  for (int x = 0; x < 20; x++)
    for (int msk = 0; msk < (1 << 20); msk++)
      if (msk >> x & 1) msks[msk] = max(msks[msk], msks[msk ^ (1 << x)]);
  int ma = 0;
  for (int x = 0; x < (1 << 20); x++)
    ma = max(ma, msks[x] + msks[((1 << 20) - 1) & ~x]);
  printf("%i\n", ma);
}
