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 long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
long long dp[550][550][2];
string s;
long long solve(long long l, long long r, long long f) {
  if (dp[l][r][f] != -1) return dp[l][r][f];
  if (l == r) return 1;
  if (l > r) return 0;
  long long best = r - l + 1;
  for (long long k = l; k < r; k++) {
    if (s[l] == s[r] && k != l && s[l] == s[k]) {
      best = min(best, (f ^ 1) + solve(l, k, 1) + solve(k, r, 1));
    } else
      best = min(best, solve(l, k, 0) + solve(k + 1, r, 0));
  }
  if (s[l] == s[r]) best = min(best, (f ^ 1) + solve(l + 1, r - 1, 0));
  return dp[l][r][f] = best;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  cin >> s;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, n - 1, 0) << "\n";
}