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;
int N;
int dp[501][501][26];
int vis[501][501][26];
int vet[501];
vector<int> G[501];
vector<int>::iterator it;
vector<pair<int, int> > V;
void comprime() {
  int a = vet[0], b = 1;
  V.clear();
  for (int i = 1; i < N; i++) {
    if (a == vet[i])
      b++;
    else {
      G[a].push_back(V.size());
      V.push_back(make_pair(a, b));
      a = vet[i];
      b = 1;
    }
  }
  G[a].push_back(V.size());
  V.push_back(make_pair(a, b));
  V.push_back(make_pair(0, 0));
}
int solve(int start, int end, int sz) {
  int cor, z;
  if (start == end) return sz > 0;
  if (start > end) return 101001001;
  if (vis[start][end][sz] == 1) return dp[start][end][sz];
  vis[start][end][sz] = 1;
  cor = V[start].first;
  dp[start][end][sz] = 1 + solve(start + 1, end, 0);
  it = lower_bound(G[cor].begin(), G[cor].end(), start + 2);
  if (it != G[cor].end() && *it <= end) {
    z = it - G[cor].begin();
    for (int i = z; i < (int)G[cor].size(); i++) {
      z = G[cor][i];
      if (z > end) break;
      dp[start][end][sz] =
          min(dp[start][end][sz],
              solve(z, end, sz + V[start].second) + solve(start + 1, z, 0));
    }
  }
  return dp[start][end][sz];
}
char str[501];
int main() {
  scanf("%d", &N);
  scanf("%s", str);
  for (int i = 0; i < N; i++) vet[i] = str[i] - 'a';
  comprime();
  printf("%d\n", solve(0, V.size() - 1, 0));
  return 0;
}