#include <bits/stdc++.h>
using namespace std;
char s[1000004];
int dp[1 << 20];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    int now = 0;
    for (int j = i; j < n; ++j) {
      int x = (1 << (s[j] - 'a'));
      if (now & x)
        break;
      else
        now |= x;
      dp[now] = j - i + 1;
    }
  }
  for (int i = 1; i < (1 << 20); ++i) {
    for (int j = 0; j < 20; ++j) {
      int x = 1 << j;
      if (!(i & x)) continue;
      dp[i] = max(dp[i], dp[i - x]);
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 20); ++i) {
    ans = max(ans, dp[i] + dp[(1 << 20) - 1 - i]);
  }
  cout << ans << endl;
}
