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>
static void print_int(int64_t n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  if (n == 0) {
    putchar('0');
    return;
  }
  int s[20], len = 0;
  while (n > 0) {
    s[len++] = n % 10 + '0';
    n /= 10;
  }
  while (len > 0) {
    putchar(s[--len]);
  }
}
static int64_t read_int(void) {
  int prev = '\0';
  int c = getchar();
  while (!('0' <= c && c <= '9')) {
    prev = c;
    c = getchar();
  }
  int64_t res = 0;
  while ('0' <= c && c <= '9') {
    res = 10 * res + c - '0';
    c = getchar();
  }
  return prev == '-' ? -res : res;
}
void run(void) {
  int32_t n = read_int();
  char *s = (char *)calloc(n + 1, sizeof(char));
  scanf("%s", s);
  int32_t *dp = (int32_t *)calloc((n + 1) * (n + 1), sizeof(int32_t));
  for (int32_t len = 1; len <= n; ++len) {
    for (int32_t l = 0; l + len <= n; ++l) {
      int32_t r = l + len;
      int32_t min = 1 + dp[((l + 1) * (n + 1) + (r))];
      for (int32_t i = l + 1; i < r; ++i) {
        if (s[l] != s[i]) continue;
        int32_t d = dp[((l + 1) * (n + 1) + (i))] + dp[((i) * (n + 1) + (r))];
        min = min > d ? d : min;
      }
      dp[((l) * (n + 1) + (r))] = min;
    }
  }
  print_int(dp[((0) * (n + 1) + (n))]);
  puts("");
}
int main(void) {
  run();
  return 0;
}