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>
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
using namespace std;
const long long maxn = 1e3 + 7;
const double eps = 1e-10;
const long long mod = 1e9 + 7;
long long dp[maxn][maxn];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  char s[maxn];
  long long n;
  cin >> n;
  cin >> s + 1;
  memset(dp, 0x3f, sizeof(dp));
  for (long long i = 1; i <= (long long)(n); i++) dp[i][i] = 1;
  for (long long len = 2; len <= n; len++) {
    for (long long l = 1; l + len - 1 <= n; l++) {
      long long r = l + len - 1;
      for (long long mid = l; mid < r; mid++) {
        if (s[l] == s[mid + 1] || s[mid] == s[mid + 1] || s[l] == s[r] ||
            s[mid] == s[r]) {
          dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid + 1][r] - 1);
        } else
          dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid + 1][r]);
      }
    }
  }
  cout << dp[1][n] << "\n";
}