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;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		String s = in.next();
		a = new int[n];
		for(int i=0; i<n; i++) {
			a[i] = s.charAt(i)-'a';
		}
		
		System.out.println(solve());
		
	}
	
	public static long solve() {
		
		long[][] dp = new long[501][501];
		
		for(int s=0; s<a.length; s++) {
			dp[s][s]=1;
		}
		
		
		for(int diff=1; diff<a.length; diff++) {
			for(int s=0; s<a.length; s++) {
				int e = s+diff;
				if (e>=a.length) continue;
				long ans=(long)1e15;
				for(int i=s+1; i<=e; i++) {
					if (a[i]==a[s]) {
						ans = Math.min(ans, dp[s+1][i-1]+dp[i][e]);
					}
				}
				ans = Math.min(ans, 1+dp[s+1][e]);
				dp[s][e] = ans;
			}
		}
		
		return dp[0][a.length-1];
	}
	
}