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>
namespace IOStream {
const int MAXR = 10000000;
char _READ_[MAXR], _PRINT_[MAXR];
int _READ_POS_, _PRINT_POS_, _READ_LEN_;
inline char readc() {
  if (!_READ_POS_) _READ_LEN_ = fread(_READ_, 1, MAXR, stdin);
  char c = _READ_[_READ_POS_++];
  if (_READ_POS_ == MAXR) _READ_POS_ = 0;
  if (_READ_POS_ > _READ_LEN_) return 0;
  return c;
}
template <typename T>
inline void read(T &x) {
  x = 0;
  register int flag = 1, c;
  while (((c = readc()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    flag = -1;
  else
    x = c - '0';
  while ((c = readc()) >= '0' && c <= '9') x = x * 10 - '0' + c;
  x *= flag;
}
template <typename T1, typename... T2>
inline void read(T1 &a, T2 &...x) {
  read(a), read(x...);
}
inline int reads(char *s) {
  register int len = 0, c;
  while (isspace(c = readc()) || !c)
    ;
  s[len++] = c;
  while (!isspace(c = readc()) && c) s[len++] = c;
  s[len] = 0;
  return len;
}
inline void ioflush() {
  fwrite(_PRINT_, 1, _PRINT_POS_, stdout), _PRINT_POS_ = 0;
  fflush(stdout);
}
inline void printc(char c) {
  if (!c) return;
  _PRINT_[_PRINT_POS_++] = c;
  if (_PRINT_POS_ == MAXR) ioflush();
}
inline void prints(const char *s, char c) {
  for (int i = 0; s[i]; i++) printc(s[i]);
  printc(c);
}
template <typename T>
inline void print(T x, char c = '\n') {
  if (x < 0) printc('-'), x = -x;
  if (x) {
    static char sta[20];
    register int tp = 0;
    for (; x; x /= 10) sta[tp++] = x % 10 + '0';
    while (tp > 0) printc(sta[--tp]);
  } else
    printc('0');
  printc(c);
}
template <typename T1, typename... T2>
inline void print(T1 x, T2... y) {
  print(x, ' '), print(y...);
}
}  // namespace IOStream
using namespace IOStream;
using namespace std;
const int MAXN = 505;
int f[MAXN][MAXN], n, m;
char str[MAXN];
int main() {
  read(n);
  reads(str + 1);
  for (int i = 1; i <= n; i++)
    if (i == 1 || str[i] != str[i - 1]) str[++m] = str[i];
  for (int i = 1; i <= m; i++) f[i][i] = 1;
  for (int i = m - 1; i > 0; i--)
    for (int j = i + 1; j <= m; j++) {
      f[i][j] = f[i + 1][j] + 1;
      for (int k = i + 1; k <= j; k++)
        if (str[k] == str[i]) f[i][j] = min(f[i][j], f[i + 1][k - 1] + f[k][j]);
    }
  printf("%d\n", f[1][m]);
  return 0;
}
