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[505][505];
set<int> a[28];
string s;
int func(int i, int j) {
  int d = INT_MAX, k;
  if (i > j) return 0;
  if (i == j - 1 || i == j) {
    if (s[i] == s[j])
      return 1;
    else
      return 2;
  }
  if (dp[i][j] != -1) return dp[i][j];
  set<int>::iterator it;
  it = a[s[i] - 97].upper_bound(i);
  if (it == a[s[i] - 97].end() || ((it != a[s[i] - 97].end()) && ((*it) > j))) {
    dp[i][j] = func(i + 1, j) + 1;
    return dp[i][j];
  }
  k = (*it);
  while (k <= j) {
    d = min(func(i + 1, k - 1) + func(k, j), d);
    it = a[s[i] - 97].upper_bound(k);
    if (it == a[s[i] - 97].end()) break;
    k = (*it);
  }
  dp[i][j] = min(d, func(i + 1, j) + 1);
  return dp[i][j];
}
int main() {
  int n, i;
  cin >> n >> s;
  for (i = 0; i < n; i++) a[s[i] - 97].insert(i);
  memset(dp, -1, sizeof(dp));
  cout << func(0, n - 1) << endl;
}