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;
int inf = 1000000005;
long long int llinf = 2000000000000000005LL;
long long int mod = 1000000007;
long long int mod9 = 1000000009;
double PI = 3.1415926535897;
double eps = 1e-10;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1, true);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = (2); i < (sq + 1); i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
bool isitprime(int n) {
  if (n < 2) return false;
  int sq = sqrt(n);
  for (int i = (2); i < (sq + 1); i++)
    if (n % i == 0) return false;
  return true;
}
template <class T>
inline T gcd(T a, T b) {
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
inline long long int bexp(long long int x, long long int n,
                          long long int m = mod) {
  long long int res = 1;
  x %= m;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
int n;
string s;
int mem[505][505];
int rec(int l, int r) {
  if (l == r) return 1;
  if (l > r) return 0;
  int &res = mem[l][r];
  if (res == -1) {
    res = 1 + rec(l + 1, r);
    for (int i = (l + 1); i < (r + 1); i++) {
      if (s[i] == s[l]) {
        res = min(res, rec(l + 1, i - 1) + rec(i, r));
      }
    }
  }
  return res;
}
int main() {
  memset(mem, -1, sizeof(mem));
  ;
  cin >> n >> s;
  cout << rec(0, n - 1) << endl;
}
