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# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

public class Monoid<T>
{
    public T Unit { get; private set; }
    Func<T, T, T> append;
    public T Append(T left, T right) => append(left, right);

    public Monoid(T unit, Func<T, T, T> append)
    {
        this.Unit = unit;
        this.append = append;
    }
}

public class Group<T> : Monoid<T>
{
    Func<T, T, T> appendInv;
    public T AppendInv(T left, T right) => appendInv(left, right);

    public Group(T unit, Func<T, T, T> append, Func<T, T, T> appendInv)
        : base(unit, append)
    {
        this.appendInv = appendInv;
    }
}

public class BinaryIndexedTree<T>
{
    T[] tree;

    public readonly int N;
    public readonly Monoid<T> Monoid;
    readonly bool supportsGroup = false;

    // O(N)
    public BinaryIndexedTree(int n, Monoid<T> monoid)
    {
        N = n;
        Monoid = monoid;
        tree = Enumerable.Repeat(monoid.Unit, n + 1).ToArray();
    }

    // O(N)
    public BinaryIndexedTree(IEnumerable<T> collection, Monoid<T> monoid)
    {
        N = collection.Count();
        Monoid = monoid;
        tree = new T[N + 1];
        for (var i = 0; i < N; i++) tree[i + 1] = collection.ElementAt(i);
        for (var i = 1; i < N; i++)
        {
            var j = i + (i & -i);
            if (j < N) tree[j] = monoid.Append(tree[j], tree[i]);
        }
    }

    // O(N)
    public BinaryIndexedTree(int n, Group<T> group)
        : this(n, (Monoid<T>)group)
    {
        supportsGroup = true;
    }

    // O(N)
    public BinaryIndexedTree(IEnumerable<T> collection, Group<T> group)
        : this(collection, (Monoid<T>)group)
    {
        supportsGroup = true;
    }

    public T this[int i]
    {
        // O(log N)
        get { return this[i, i]; }

        // O(log N)
        set
        {
            if (!supportsGroup) throw new InvalidOperationException();
            var group = (Group<T>)Monoid;
            Append(i, group.AppendInv(value, this[i]));
        }
    }

    public T this[int i, int j]
    {
        // O(log N)
        get
        {
            if (!supportsGroup) throw new InvalidOperationException();
            var group = (Group<T>)Monoid;
            var acc = group.Unit;
            j++;
            for (; j > i; j -= j & -j) acc = group.Append(acc, tree[j]);
            for (; i > j; i -= i & -i) acc = group.AppendInv(acc, tree[i]);
            return acc;
        }
    }

    // O(log N)
    public T Concat(int i)
    {
        var acc = Monoid.Unit;
        for (i++; i > 0; i -= i & -i) acc = Monoid.Append(acc, tree[i]);
        return acc;
    }

    // O(log N)
    public void Append(int i, T d)
    {
        for (i++; i <= N; i += i & -i) tree[i] = Monoid.Append(tree[i], d);
    }
}

static class Extentions
{
}

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static bool CanBePalindrome(IEnumerable<int> cnts) => cnts.Count(x => x % 2 == 1) <= 1;

    static void Solve(IO io)
    {
        var s = io.S;
        var bit = new BinaryIndexedTree<int>[26];

        for (var i = 0; i < 26; i++)
        {
            bit[i] = new BinaryIndexedTree<int>(s.Length,
                new Group<int>(0, (x, y) => x + y, (x, y) => x - y));

            for (var j = 0; j < s.Length; j++) if (s[j] == i + 'a') bit[i][j] = 1;
        }

        var dp = new long?[s.Length];

        Func<int, long> Search = null; Search = i =>
        {
            if (i == s.Length - 1) return 1;
            if (i > s.Length - 1) return 0;
            if (dp[i].HasValue) return dp[i].Value;

            var tail = s.Substring(i);
            var r = 1145141919810L;

            for (var j = tail.Length - 1; j >= 0; j--)
            {
                var tmp = 0;
                for (var k = 0; k < 26; k++) if (bit[k][i, i + j] % 2 == 1) tmp++;
                if (tmp <= 1) r = Min(r, 1 + Search(i + j + 1));
            }

            return (dp[i] = r).Value;
        };

        var ans = Search(0);
        io.Write(ans);
    }
}