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;
const long double pi = acos(-1);
const long long int inf = 1e18, M = 1e9 + 7;
const long long int N = 5e2 + 5, NN = 26;
long long int dp[N][N];
vector<long long int> arr[NN];
long long int sz[NN];
long long int n;
string s;
long long int rec(long long int l, long long int r) {
  if (l > r) return 0;
  if (l == r) return 1;
  long long int& res = dp[l][r];
  if (res != -1) return res;
  res = rec(l, r - 1) + 1;
  long long int x = s[r] - 'a', cur;
  for (long long int i = sz[x] - 1; i >= 0; --i) {
    cur = arr[x][i];
    if (l <= cur && cur < r) res = min(res, rec(l, cur) + rec(cur + 1, r - 1));
  }
  return res;
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> s;
  for (long long int i = 0; i < n; ++i) arr[s[i] - 'a'].push_back(i);
  for (long long int i = 0; i < 26; ++i) sz[i] = arr[i].size();
  long long int ans = rec(0, n - 1);
  cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}