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;
vector<long long> vec(30);
long long memo[500][500];
long long n;
string s, sUniq = "";
string removeDuplicatesFromString(string str) {
  int counter = 0;
  int i = 0;
  int size = str.size();
  int x;
  int length = 0;
  while (i < size) {
    x = str[i] - 97;
    if ((counter & (1 << x)) == 0) {
      str[length] = 'a' + x;
      counter = counter | (1 << x);
      length++;
    }
    i++;
  }
  return str.substr(0, length);
}
long long DP(long long i, long long j) {
  long long temp = 10000000005;
  if (i == j) {
    return 1;
  } else if (memo[i][j] != -1) {
    return memo[i][j];
  } else {
    for (long long k = i + 1; k <= j; k++) {
      if (sUniq[k] == sUniq[i]) {
        temp = min(temp, DP(i + 1, k - 1) + DP(k, j));
      }
    }
    return memo[i][j] = min(temp, 1 + DP(i + 1, j));
  }
}
int main() {
  memset(memo, -1, sizeof(memo));
  cin >> n >> s;
  sUniq = s[0];
  for (long long i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) sUniq += s[i];
  }
  cout << DP(0, sUniq.size() - 1);
  return 0;
}