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;
int is1(int x) {
  if (x <= 3) return true;
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int is(int x) {
  int a = 0;
  for (int i = 1; i < x; i++) {
    if (x % i == 0) {
      a += i * i;
    }
  }
  int sq = sqrt(a);
  if (sq * sq == a) return true;
  return false;
}
int n;
int dp[550][550][2];
string s;
int solve(int l, int r, int f) {
  if (dp[l][r][f] != -1) return dp[l][r][f];
  if (l == r) return 1;
  if (l > r) return 0;
  int modos = 1000000000;
  if (s[l] == s[r]) {
    if (f)
      modos = min(modos, solve(l + 1, r - 1, (l + 1 < n && s[l + 1] == s[l])));
    else
      modos =
          min(modos, 1 + solve(l + 1, r - 1, (l + 1 < n && s[l + 1] == s[l])));
    for (int j = l + 1; j < r; j++) {
      if (s[j] == s[l])
        modos = min(modos, (f ^ 1) + solve(l, j, 1) + solve(j, r, 1));
      else
        modos = min(modos, solve(l, j, 0) + solve(j + 1, r, 0));
    }
  }
  for (int j = l; j < r; j++) {
    modos = min(modos, solve(l, j, 0) + solve(j + 1, r, 0));
  }
  return dp[l][r][f] = modos;
}
int main() {
  cin >> n;
  cin >> s;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, n - 1, 0) << endl;
}