Problem: You are given a string s of length n consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the substring you delete are equal. For example, after deleting substring bbbb from string abbbbaccdd we get the string aaccdd.

Calculate the minimum number of operations to delete the whole string s.

Input

The first line contains one integer n (1 ≤ n ≤ 500) — the length of string s.

The second line contains the string s (|s| = n) consisting of lowercase Latin letters.

Output

Output a single integer — the minimal number of operation to delete string s.

Examples

Input


5
abaca


Output


3

Input


8
abcddcba


Output


4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
template <typename Type>
string ToString(const Type& val) {
  stringstream ss;
  ss << val;
  return ss.str();
}
long long __gcd(long long a, long long b) {
  while (a != 0) {
    long long __t = b % a;
    b = a;
    a = __t;
  }
  return b;
}
inline long long absl(long long x) { return (x < 0 ? -x : x); }
inline long long sqr(long long x) { return x * x; }
long long ModPower(long long x, long long st, long long mod) {
  if (!st) return 1;
  if (st & 1) return (x % mod) * ModPower(x, st - 1, mod) % mod;
  return sqr(ModPower(x, st >> 1, mod)) % mod;
}
long long fact(unsigned x) {
  long long res = 1;
  for (; x > 0; x--) res *= x;
  return res;
}
long long __lcm(long long a, long long b, long long gcd = 0) {
  if (!gcd) gcd = __gcd(a, b);
  return (a / gcd) * b;
}
vector<long long> sumArr;
long long getSum(unsigned l, unsigned r) {
  return (l ? sumArr[r] - sumArr[l - 1] : sumArr[r]);
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
  ios_base::sync_with_stdio(false);
  unsigned N;
  cin >> N;
  string s;
  cin >> s;
  vector<vector<long long> > d(N, vector<long long>(N));
  for (unsigned i = 0; i < N; i++) d[i][i] = 1;
  for (unsigned k = 2; k <= N; k++) {
    for (unsigned i = 0; i <= N - k; i++) {
      unsigned j = i + k - 1;
      d[i][j] = d[i + 1][j] + (s[i] != s[j]);
      for (int h = i + 1; h <= (int)j; h++) {
        if (s[h] == s[i]) d[i][j] = min(d[i][j], d[i + 1][h - 1] + d[h][j]);
      }
    }
  }
  cout << d[0].back();
  return 0;
}