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>
#pragma GCC optimize("O3")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
int gcd(int a, int b) {
  if (b) return gcd(b, a % b);
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<int> vec[100];
int dp[505][505];
int pd[505];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < (int)((s).size()); i++) {
    vec[s[i] - 'a'].push_back(i + 1);
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= n; j++) pd[i] = 1e9;
    for (int j = i; j <= n; j++) {
      if (j == i) {
        dp[i][j] = 1;
        pd[j] = 0;
        continue;
      }
      dp[i][j] = 1000;
      pd[j] = dp[i][j - 1];
      for (int jj = i; jj <= j - 1; jj++) {
        if (s[jj - 1] == s[j - 1]) {
          pd[j] = min(pd[j], pd[jj] + dp[jj + 1][j - 1]);
        }
      }
      for (int jj = i; jj <= j; jj++) {
        dp[i][j] = min(dp[i][j], pd[jj] + dp[jj + 1][j]);
      }
      dp[i][j]++;
      for (int jj = i; jj <= j; jj++) {
        dp[i][j] = min(dp[i][j], dp[i][jj] + dp[jj + 1][j]);
      }
    }
  }
  return cout << dp[1][n], 0;
}