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 dp[1000][1000];
string s;
string removeDuplicates(string second) {
  int n = second.length();
  string c = "";
  if (n < 2) return second;
  int j = 0;
  c = c + second[0];
  for (int i = 1; i < n; i++) {
    if (second[i] != second[i - 1]) {
      c = c + second[i];
    }
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int len;
  cin >> len;
  string t;
  cin >> t;
  s = removeDuplicates(t);
  long long int n = s.length();
  for (long long int i = 0; i < n + 10; i++) {
    for (long long int j = 0; j < n + 10; j++) dp[i][j] = 0;
  }
  for (long long int i = 0; i < n + 10; i++) dp[i][i] = 1;
  char temp;
  long long int k;
  for (long long int l = 2; l <= n; l++) {
    for (long long int i = 0; i < n - l + 1; i++) {
      long long int j = i + l - 1;
      temp = s[j];
      dp[i][j] = dp[i][j - 1] + 1;
      for (k = j - 1; k >= i; k--) {
        if (s[k] == temp) {
          dp[i][j] = min(dp[i][k] + dp[k + 1][j - 1], dp[i][j]);
        }
      }
    }
  }
  cout << dp[0][n - 1] << endl;
  return 0;
}