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>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T>
const T &var_min(const T &t) {
  return t;
}
template <typename T>
const T &var_max(const T &t) {
  return t;
}
template <typename Head, typename... Tail>
const Head &var_min(const Head &head, const Tail &...tail) {
  return min(head, var_min(tail...));
}
template <typename Head, typename... Tail>
const Head &var_max(const Head &head, const Tail &...tail) {
  return max(head, var_max(tail...));
}
template <typename T, typename... Tail>
void chmin(T &t, const Tail &...tail) {
  t = var_min(t, tail...);
}
template <typename T, typename... Tail>
void chmax(T &t, const Tail &...tail) {
  t = var_max(t, tail...);
}
void debug_func_preffix(const string &s) {
  if (s.size()) cout << s << " = ";
}
template <typename T>
void debug_func(const T &t, const string &s = "") {
  debug_func_preffix(s);
  cout << t << ((s).size() ? "\n" : "");
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
  debug_func_preffix(s);
  cout << "(";
  debug_func(p.first);
  cout << ", ";
  debug_func(p.second);
  cout << ")" << ((s).size() ? "\n" : "");
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
  for (ll i = 0; i < v.size(); i++) {
    string t = s + "[" + to_string(i) + "]";
    debug_func(v[i], t);
  }
}
V<pair<char, ll>> ccnt;
const ll INF = 5e15;
VV<ll> dp(510, V<ll>(510, INF));
ll calc(ll l, ll r) {
  if (l == r) return 1;
  if (l > r) return 0;
  if (dp[l][r] != INF) return dp[l][r];
  ll ret = calc(l + 1, r) + 1;
  for (ll i = l + 2; i <= r; i++) {
    if (ccnt[i].first != ccnt[l].first) continue;
    chmin(ret, calc(l + 1, i - 1) + calc(i, r));
  }
  return dp[l][r] = ret;
}
int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  S += '0';
  ll cnt = 0;
  char now = 0;
  for (char c : S) {
    if (now != c) {
      if (now) ccnt.emplace_back(now, cnt);
      cnt = 0;
      now = c;
    } else {
      cnt++;
    }
  }
  cout << calc(0, ccnt.size() - 1) << '\n';
  return 0;
}