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 <class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T> >;
const int LM = 500;
long long INF = 1e9;
string s;
int n, a[LM + 2], ans = INF;
int dp[LM + 2][LM + 2][28];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 1; i <= n; i++) {
    a[i] = s[i - 1] - 'a' + 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= 26; x++) {
      dp[i][i][x] = (a[i] == x ? 0 : INF);
    }
  }
  for (int l = n; l >= 1; l--) {
    for (int r = l + 1; r <= n; r++) {
      for (int x = 1; x <= 26; x++) {
        if (x == a[r]) {
          dp[l][r][x] = dp[l][r - 1][x];
        } else {
          int m = dp[l][r - 1][x] + 1;
          for (int j = l + 1; j <= r - 1; j++) {
            m = min(m, dp[j][r - 1][a[r]] + 1 + dp[l][j - 1][x]);
          }
          dp[l][r][x] = m;
        }
      }
    }
  }
  for (int i = 1; i <= 26; i++) {
    ans = min(ans, dp[1][n][i] + 1);
  }
  cout << ans << endl;
}