Problem:
Score : 700 points

Problem Statement

We have a string s consisting of lowercase English letters.
Snuke is partitioning s into some number of non-empty substrings.
Let the subtrings obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ... + s_N holds.)
Snuke wants to satisfy the following condition:

For each i (1 \leq i \leq N), it is possible to permute the characters in s_i and obtain a palindrome.

Find the minimum possible value of N when the partition satisfies the condition.

Constraints

1 \leq |s| \leq 2 \times 10^5

s consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s

Output

Print the minimum possible value of N when the partition satisfies the condition.

Sample Input 1

aabxyyzz

Sample Output 1

2

The solution is to partition s as aabxyyzz = aab + xyyzz.
Here, aab can be permuted to form a palindrome aba, and xyyzz can be permuted to form a palindrome zyxyz.

Sample Input 2

byebye

Sample Output 2

1

byebye can be permuted to form a palindrome byeeyb.

Sample Input 3

abcdefghijklmnopqrstuvwxyz

Sample Output 3

26

Sample Input 4

abcabcxabcx

Sample Output 4

3

The solution is to partition s as abcabcxabcx = a + b + cabcxabcx.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

const int MAX = 200000 +10;

map<pair<int,int>, int> dp;
char arr[MAX];
int sum[MAX][26];

bool ispal(int l, int r) {
    int cnt = 0;
    REP(i, 26) {
        if((sum[r][i] - sum[l-1][i]) % 2 == 1) cnt++;
    }
    return cnt <= 1;
}

int solve(int l, int r) {
    if(l == r) return 1;
    if(l > r) return 0;
    if(dp.find(make_pair(l, r))!=dp.end()) return dp[make_pair(l, r)];
    if(ispal(l, r)) return dp[make_pair(l, r)] = 1;

    int l1 = l, r1 = r, l2 = l, r2 = r;
    while(!ispal(l1, r1)) {
        vi tar;
        REP(i, 26) {
            if((sum[r1][i] - sum[l1-1][i]) % 2 == 1) tar.push_back(i);
        }
        int sl = l1, sr = r1;
        while(sl < sr) {
            int mid = (sl + sr + 1) / 2;
            int cc = 0;
            REP(i, 26) {
                if(sum[r1][i] != sum[mid-1][i]) cc++;
            }
            if(cc >= (int)tar.size() - 1) sl = mid;
            else sr = mid-1;
        }
        r1 = sl - 1;
    }
    while(!ispal(l2, r2)) {
        vi tar;
        REP(i, 26) {
            if((sum[r2][i] - sum[l2-1][i]) % 2 == 1) tar.push_back(i);
        }
        int sl = l2, sr = r2;
        while(sl < sr) {
            int mid = (sl + sr) / 2;
            int cc = 0;
            REP(i, 26) {
                if(sum[mid][i] != sum[l2-1][i]) cc++;
            }
            if(cc >= (int)tar.size() - 1) sr = mid;
            else sl = mid+1;
        }
        l2 = sl + 1;
    }

    return dp[make_pair(l, r)] = min(solve(r1+1, r), solve(l, l2-1)) + 1;
}

void solve() {

    int n;
    scanf("%s", arr+1);
    n = strlen(arr+1);
    REPP(i, 1, n) {
        REP(j, 26) {
            sum[i][j] = sum[i-1][j];
        }
        sum[i][arr[i] - 'a']++;
    }

    printf("%d\n", solve(1, n));
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}