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;
void solve() {}
const long long maxn = 505;
long long n;
long long dp[maxn][maxn];
string s;
void f(long long l, long long r) {
  if (l > r) {
    dp[l][r] = 0;
  } else if (l == r) {
    dp[l][r] = 1;
  } else {
    if (dp[l + 1][r] == -1) f(l + 1, r);
    dp[l][r] = 1 + dp[l + 1][r];
    for (long long i = l + 1; i <= r; i++) {
      if (s[l] == s[i]) {
        if (dp[l + 1][i - 1] == -1) f(l + 1, i - 1);
        if (dp[i][r] == -1) f(i, r);
        if (false)
          cerr << "for " << l << " " << r << " we can tranistion using " << i
               << " to get " << dp[l + 1][i - 1] + dp[i][r] << '\n';
        if (false) cerr << s[l] << " " << s[i] << '\n';
        dp[l][r] = min(dp[l][r], dp[l + 1][i - 1] + dp[i][r]);
      }
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 0; i < maxn; i++) {
    for (long long j = 0; j < maxn; j++) {
      dp[i][j] = -1;
    }
  }
  cin >> n;
  cin >> s;
  s = "." + s;
  f(1, n);
  cout << dp[1][n] << '\n';
  if (false) cerr << ("dp[2][2]") << " is " << (dp[2][2]) << '\n';
  if (false) cerr << ("dp[3][n]") << " is " << (dp[3][n]) << '\n';
}