#include <bits/stdc++.h>
using namespace std;
int bincount(int k) {
  int ans = 0;
  while (k) {
    if (k & 1) {
      ans += 1;
    }
    k >>= 1;
  }
  return ans;
}
int main() {
  string s;
  while (cin >> s) {
    vector<int> dp(1 << 20);
    vector<int> bitmask(20);
    for (int i = 0; i < 20; ++i) {
      bitmask[i] = 1 << i;
    }
    for (int i = 0; i < int(s.size()); ++i) {
      int ret = 0;
      for (int j = i; j < int(s.size()); ++j) {
        if (ret & (1 << (s[j] - 'a'))) {
          break;
        }
        ret |= (1 << (s[j] - 'a'));
        dp[ret] = j - i + 1;
      }
    }
    for (int i = 0; i < (1 << 20); ++i) {
      for (int j = 0; j < 20; ++j) {
        if (i & bitmask[j]) {
          dp[i] = max(dp[i], dp[i ^ bitmask[j]]);
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < (1 << 20); ++i) {
      if (dp[i] == bincount(i)) {
        ans = max(ans, dp[i] + dp[~i & ((1 << 20) - 1)]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
