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;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
const double pi = acos(-1);
const int oo = 0x3f3f3f3f;
int cmp(double x, double y = 0, double tol = 1e-9) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
const int MAX_N = 200010;
int dp[510][510];
int main() {
  int N;
  scanf("%d", &N);
  string s;
  cin >> s;
  memset(dp, 0, sizeof(dp));
  for (int len = 1; len <= int(N); len++) {
    for (int i = 0, j = len - 1; j < N; i++, j++) {
      if (len == 1)
        dp[i][j] = 1;
      else {
        dp[i][j] = 1 + dp[i + 1][j];
        if (s[i] == s[i + 1]) dp[i][j] = min(1 + dp[i + 2][j], dp[i][j]);
        int t = i;
        while (t < j && s[t] == s[i]) t++;
        if (t == j && s[t] == s[i]) dp[i][j] = 1;
        for (int k = i + 2; k <= j; k++) {
          if (s[i] == s[k])
            dp[i][j] = min(1 + dp[i + 1][k - 1] + dp[k + 1][j], dp[i][j]);
        }
        if (s[i] == s[j]) {
          dp[i][j] = min(1 + dp[i + 1][j - 1], dp[i][j]);
          for (int k = i + 1; k < j; k++)
            if (s[i] == s[k])
              dp[i][j] = min(dp[i + 1][k - 1] + dp[k + 1][j], dp[i][j]);
        }
        for (int k = i + 1; k < j; k++)
          dp[i][j] = min(dp[i][k] + dp[k + 1][j], dp[i][j]);
      }
    }
  }
  printf("%d\n", dp[0][N - 1]);
  return 0;
}