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.util.Arrays;
import java.util.Scanner;

public class P1132F {

	static int n;
	static int[] a;
	static int[] next;
	static long[][] dp;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		String s = in.next();
		a = new int[n];
		dp = new long[501][501];
		for(int i=0; i<501; i++) {
			Arrays.fill(dp[i], -1);
		}
		for(int i=0; i<n; i++) {
			a[i] = s.charAt(i)-'a';
		}
		next = new int[n];
		Arrays.fill(next, n);
		
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				if (a[j]==a[i]) {
					next[i]=j;
					break;
				}
			}
		}
		
//		for(int x: next) {
//			System.out.print(x+" ");
//		}
//		System.out.println();
		
		System.out.println(solve(0, a.length-1));
		
	}
	
	public static long solve(int s, int e) {
//		System.out.println(s+" "+e);
		if (s==e) return 1;
		else if (s>e) return 0;

		if (dp[s][e]!=-1) return dp[s][e];

		long ans=(long)1e15;
		
		ans = Math.min(ans, 1+solve(s+1, e));
		
		for(int i=s+1; i<=e; i++) {
			if (a[i]==a[s]) {
				ans = Math.min(solve(s+1, i-1)+solve(i, e), ans);
			}
		}
		
		return dp[s][e]=ans;
	}

}