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;
template <typename T>
inline void read(T& x) {
  bool Neg = false;
  char c;
  for (c = getchar(); c<'0' | c> '9'; c = getchar())
    if (c == '-') Neg = !Neg;
  x = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  if (Neg) x = -x;
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  T p = 1;
  for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
  for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("1132F"
            ".inp",
            "r")) {
    freopen(
        "1132F"
        ".inp",
        "r", stdin);
    freopen(
        "1132F"
        ".out",
        "w", stdout);
  }
}
const int N = 502;
int n, f[N][N];
string s;
void readinp() {
  cin >> n;
  cin >> s;
  s = ' ' + s;
}
void solve() {
  for (int l = int(1); l <= int(n); l++) {
    for (int i = int(1); i <= int(n - l + 1); i++) {
      int j = i + l - 1;
      if (l == 1)
        f[i][j] = 1;
      else if (l == 2) {
        if (s[i] == s[j])
          f[i][j] = 1;
        else
          f[i][j] = 2;
      } else {
        f[i][j] = f[i + 1][j] + 1;
        for (int k = int(i + 1); k <= int(j); k++) {
          if (s[i] == s[k]) f[i][j] = min(f[i][j], f[i + 1][k - 1] + f[k][j]);
        }
      }
    }
  }
  cout << f[1][n];
}
int main() {
  setIO();
  int t = 1;
  while (t--) {
    readinp();
    solve();
  }
}