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;
const long long N = 666;
inline long long read() {
  long long s(0), w(1);
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
inline void put(long long x) {
  if (!x) putchar('0');
  if (x < 0) putchar('-'), x = -x;
  long long num(0);
  char c[66];
  while (x) c[++num] = x % 10 + 48, x /= 10;
  while (num) putchar(c[num--]);
  return (void)(putchar('\n'));
}
long long n;
long long f[N][N];
char s[N];
signed main() {
  long long i, j, k, l;
  n = read();
  scanf("%s", s + 1);
  memset(f, 0x3f, sizeof f);
  for (i = 1; i <= n; ++i) f[i][i] = 1;
  for (l = 1; l <= n; ++l) {
    for (i = 1, j = 1 + l; j <= n; ++i, ++j) {
      if (s[i] == s[j])
        f[i][j] = min(f[i + 1][j], f[i][j - 1]);
      else {
        for (k = i; k < j; ++k) f[i][j] = min(f[i][j], f[i][k] + f[k + 1][j]);
      }
    }
  }
  put(f[1][n]);
  return 0;
}