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:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	static StringTokenizer st;
	static PrintWriter out;
	static int[][] dp = new int[501][501];


	public static String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static int solve(String str, int l, int r) {
		if(l > r) {
			return 0;
		}

		if(dp[l][r] != -1) {
			return dp[l][r];
		}

		int res = 1 + solve(str, l, r - 1);

		for (int i = r - 1; i >= l; i--) {
			if(str.charAt(i) == str.charAt(r)) {
				res = Math.min(res, solve(str, l, i - 1) + solve(str, i + 1, r));
			}
		}
		dp[l][r] = res;
		return res;
	}

	public static void main(String[] args) throws IOException {

		for (int i = 0; i <501; i++) {
			for (int j = 0; j <501; j++) {
				dp[i][j] = -1;
			}
		}

		int n = nextInt();

		String str = next();

		System.out.println(solve(str, 0 , n - 1));
	}
}