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 double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);
int irand(int lo, int hi) {
  return (((double)rand()) / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;
}
string toString(long long x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
long long toNumber(string S) {
  long long ret;
  sscanf(S.c_str(), "%lld", &ret);
  return ret;
}
const int INF = (int)2e9;
const long long MOD = (long long)1e9 + 7;
char s[505];
int dp[505][505];
int solve(int a, int b) {
  int& res = dp[a][b];
  if (res != -1) return res;
  int flag = 1;
  for (int i = a; i <= b; i += 1) flag &= s[i] == s[a];
  if (flag) return res = 1;
  res = (int)1e3;
  for (int i = a; i <= b - 1; i += 1) {
    res = min(res, solve(a, i) + solve(i + 1, b));
  }
  if (s[a] == s[b]) {
    int x = a;
    for (; s[x] == s[a]; x++)
      ;
    res = min(res, solve(x, b));
  }
  return res;
}
int main() {
  for (int i = 0; i < 503; i++)
    for (int j = 0; j < 503; j++) dp[i][j] = -1;
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  printf("%d\n", (int)solve(1, n));
  return 0;
}