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
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
const long long INF = numeric_limits<long long>::max() / 2;
const long double PI = 3.1415926535898;
const long long MOD = 1e9 + 7;
const long long LIM = 5e2 + 5;
long long fpow(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = fpow(x, y / 2);
  if (y % 2 == 0)
    return (temp * temp) % MOD;
  else
    return (x * ((temp * temp) % MOD)) % MOD;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long dp[LIM][LIM];
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  for (long long len = 1; len <= n; ++len) {
    for (long long l = 0; l + len <= n; ++l) {
      long long r = l + len - 1;
      if (l == r) {
        dp[l][r] = 1;
        continue;
      }
      dp[l][r] = min(dp[l + 1][r], dp[l][r - 1]) + 1;
      for (long long i = l + 1; i <= r; ++i) {
        if (s[l] == s[i]) {
          long long cnt1 = (i - 1 >= l + 1 ? dp[l + 1][i - 1] : 0);
          long long cnt2 = dp[i][r];
          dp[l][r] = min(dp[l][r], cnt1 + cnt2);
        }
      }
      for (long long i = r - 1; i >= l; --i) {
        if (s[r] == s[i]) {
          long long cnt1 = (r - 1 >= i + 1 ? dp[i + 1][r - 1] : 0);
          long long cnt2 = dp[l][i];
          dp[l][r] = min(dp[l][r], cnt1 + cnt2);
        }
      }
    }
  }
  long long ans = dp[0][n - 1];
  cout << ans << "\n";
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  { solve(); }
  return 0;
}
