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 read() {
  int a = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
  return a * f;
}
void write(int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar((x % 10) ^ 48);
}
const int mod = 1e9 + 7;
const int N = 5e2 + 5;
const int INF = 0x3f3f3f3f;
int f[N][N], n;
char s[N];
signed main() {
  n = read();
  for (int i = 0; i < n; i++) s[i] = getchar();
  for (int len = 0; len < n; len++) {
    for (int i = 0; i < n - len + 1; i++) {
      int j = i + len;
      int minn = INF;
      if (i == j) {
        f[i][j] = 1;
        continue;
      }
      for (int k = i; k < j; k++) {
        if (s[j] == s[k])
          minn = min(minn, f[i][k] + f[k + 1][j - 1]);
        else
          minn = min(minn, f[i][k] + f[k + 1][j - 1] + 1);
      }
      f[i][j] = minn;
    }
  }
  write(f[0][n - 1]);
  putchar('\n');
  return 0;
}