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 JAVA):

Solution:
//package codeforces;

import java.util.Scanner;

/**
 * https://codeforces.com/problemset/problem/1132/F
 */
public class ClearTheString {


	static int[][] f;

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		in.nextLine();
		String s = in.nextLine();
		f = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				f[i][j] = -1;
			}
		}

		System.out.println(solve(0, n - 1, s));
		in.close();
	}

	private static int solve(int x, int y, String s) {
		if (f[x][y] == -1) {
			if (x == y) {
				f[x][y] = 1;
			} else if (x > y) {
				f[x][y] = 0;
			} else {
				f[x][y] = 1 + solve(x + 1, y, s);
				for (int i = x + 1; i <= y; i++) {
					if (s.charAt(x) == s.charAt(i)) {
						f[x][y] = Math.min(f[x][y], solve(x + 1, i - 1, s) + solve(i, y, s));
					}
				}

			}

		}
		return f[x][y];
	}
}