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;
const double DINF = numeric_limits<double>::infinity();
const long long MOD = 1e9 + 7;
const double EPS = 1e-7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw_(time(0));
uniform_int_distribution<long long> rd_;
long long randomll() { return rd_(mmtw_); }
long long rnd(long long x, long long y) { return rd_(mmtw_) % (y - x + 1) + x; }
const int MAXN = 505;
int n;
string second;
int dp[MAXN][MAXN];
int pos[26];
void compress() {
  string t;
  t.push_back(second[0]);
  for (auto ch : second) {
    if (ch != t.back()) t.push_back(ch);
  }
  second = t;
  n = second.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> second;
  compress();
  for (int i = 0; i < n; ++i) {
    dp[i][i - 1] = 0;
    dp[i][i] = 1;
  }
  for (int len = 2; len <= n; ++len) {
    for (int l = 0; l + len - 1 < n; ++l) {
      int r = l + len - 1;
      dp[l][r] = dp[l][r - 1] + 1;
      for (int i = l; i < r; ++i) {
        if (second[i] != second[r]) continue;
        dp[l][r] = min(dp[l][r], dp[l][i - 1] + dp[i + 1][r]);
      }
    }
  }
  cout << dp[0][n - 1] << endl;
}