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;
template <typename... T>
void print1(T... t) {
  ((cout << t << " "), ...);
}
template <typename... T>
void print2(T... t) {
  vector<vector<long long>> ans = {t...};
  for (long long i = 0; i < (long long)ans.size(); i++) {
    if (i != 0)
      cout << "\t\t";
    else
      cout << "\t";
    for (long long j = 0; j < (long long)ans[i].size(); j++) {
      cout << ans[i][j] << " ";
    }
    if (i != (long long)ans.size() - 1) cout << endl;
  }
}
template <typename T>
void printV(T vec) {
  for (int i = 0; i < (long long)vec.size(); i++)
    cout << vec[i] << " " << flush;
  cout << endl;
}
const int INF = 1e9 + 5;
template <typename T>
void itR(T map) {
  for (auto itr = map.begin(); itr != map.end(); itr++) {
    cout << " [ "
            "itr->first, itr->second"
         << " : ";
    print1(itr->first, itr->second);
    cout << "]" << endl;
    ;
  }
  cout << endl;
}
long long solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long dp[s.size()][s.size()];
  for (int i = 0; i < (long long)n; i++) {
    for (int j = 0; j < (long long)n; j++) {
      dp[i][j] = INF;
    }
  }
  for (int i = 0; i < (long long)s.size(); i++) {
    dp[i][i] = 1;
  }
  for (int size = 1; size < (long long)s.size(); size++) {
    for (int l = 0; l < (long long)s.size(); l++) {
      long long r = size + l;
      if (r >= (long long)s.size()) continue;
      long long a = INF;
      for (int i = l + 1; i <= r; i++) {
        if (s[l] == s[i])
          a = min(a, ((i - 1 < l + 1) ? 0 : dp[l + 1][i - 1]) + dp[i][r]);
      }
      dp[l][r] = min(a, 1 + dp[l + 1][r]);
    }
  }
  return dp[0][s.size() - 1];
}
int main() {
  cout << setprecision(10);
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long ans = solve();
  cout << ans << endl;
  return 0;
}