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.*;
import java.io.*;
 
public class Main {
	public static void main(String args[]) {new Main().work();}
	
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	void work() {		
		int n=in.nextInt();
		String str=in.next();
		long[][] dp=new long[n][n];
		out.println(dfs(str,0,n-1,dp));
		out.flush();
	}
	
	long dfs(String str,int s,int e,long[][] dp){
	    if(s>e) return 0;
	    if(dp[s][e]>0) return dp[s][e];
	    dp[s][e]=1+dfs(str,s+1,e,dp);
        for(int i=s+1;i<=e;i++){
            if(str.charAt(i)==str.charAt(s)){
                dp[s][e]=Math.min(dfs(str,s+1,i-1,dp)+dfs(str,i,e,dp),dp[s][e]);
            }
        }	    
        return dp[s][e];
	}
}