#include <bits/stdc++.h>
using namespace std;
string s;
int gg;
int n;
int f[1 << 20];
void inp() {
  cin >> s;
  n = s.size();
}
int getbit(int m, int x) { return (m >> x) & 1; }
void pre() {
  for (int i = 0; i < n; i++) {
    int c = s[i] - 'a';
    int tmp = 1 << c;
    f[tmp] = 1;
    for (int j = i - 1; j >= 0; j--) {
      c = s[j] - 'a';
      if (getbit(tmp, c) == 1) break;
      tmp |= 1 << c;
      f[tmp] = i - j + 1;
    }
  }
}
void proc() {
  gg = 1 << 20;
  gg--;
  for (int i = 1; i <= gg; i++) {
    for (int j = 0; j < 20; j++)
      if (getbit(i, j) == 1) {
        f[i] = max(f[i], f[i ^ (1 << j)]);
      }
  }
  int ans = 0;
  for (int i = 1; i <= gg; i++) {
    ans = max(ans, f[i] + f[gg - i]);
  }
  cout << ans;
}
int main() {
  inp();
  pre();
  proc();
  return 0;
}
