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;
long long int nob(long long int x) {
  long long int s = 0;
  while (x) s += x % 2, x /= 2;
  return s;
}
int main() {
  long long int n, i, j, k;
  string s;
  cin >> n >> s;
  ios_base::sync_with_stdio(false);
  vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0));
  for (i = 1; i <= n; i++) v[i][i] = 1;
  for (i = 1; i < n; i++) v[i][i + 1] = (s[i - 1] != s[i]) + 1;
  for (i = 2; i <= n; i++) {
    for (j = 1; j <= n - i; j++) {
      if (s[j - 1] == s[i + j - 1])
        v[j][i + j] = min(v[j][i + j - 1], v[j + 1][i + j]);
      else
        v[j][i + j] = min(v[j][i + j - 1], v[j + 1][i + j]) + 1;
      for (k = j; k < i + j; k++)
        if (s[k - 1] == s[i + j - 1])
          v[j][i + j] = min(v[j][i + j], v[j][k] + v[k + 1][i + j - 1]);
    }
  }
  cout << v[1][n] << endl;
}