#include <bits/stdc++.h>
const int N = 20;
int n, dp[1 << N];
std::string str;
int main() {
  std::cin >> str;
  n = str.size();
  for (int i = 0; i < n; i++) {
    int cur = 0;
    for (int j = 0; i + j < n; j++) {
      if (cur & (1 << (str[i + j] - 'a'))) {
        break;
      }
      cur |= (1 << (str[i + j] - 'a'));
      dp[cur] = j + 1;
    }
  }
  for (int i = 0; i < (1 << 20); i++) {
    for (int j = 0; j < 20; j++) {
      if ((i & (1 << j)) == 0) {
        dp[i | (1 << j)] = std::max(dp[i | (1 << j)], dp[i]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 20); i++) {
    ans = std::max(ans, dp[i] + dp[((1 << 20) - 1) ^ i]);
  }
  std::cout << ans << std::endl;
  return 0;
}
