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 dp[600][600], a;
string st;
int solve(int s, int sz) {
  if (s >= a || sz <= 0 || s + sz > a) return 0;
  if (sz == 1) return 1;
  if (dp[s][sz] != 0) return dp[s][sz];
  dp[s][sz - 1] = solve(s, sz - 1);
  dp[s + 1][sz - 1] = solve(s + 1, sz - 1);
  dp[s][sz] = 1 + dp[s + 1][sz - 1];
  int numP = 1, numN = sz - 1;
  for (int i = s + 1; i < s + sz; ++i) {
    if (st[i] == st[s]) {
      dp[s][sz] = min(dp[s][sz], dp[s + 1][numP - 1] + dp[i][numN]);
    }
    numP++;
    numN--;
  }
  return dp[s][sz];
}
int main() {
  cin >> a >> st;
  cout << solve(0, a) << endl;
  return 0;
}