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

public class A
{

	static StringBuilder st = new StringBuilder();
	
	static int [][] memo ;
	static char [] s ; 
	
	static int dp(int l , int r )
	{
		if(l > r) return 0 ; 
		
		if(memo[l][r] != -1)return memo[l][r] ; 
		
		int ans  = dp(l + 1, r) + 1 ;
		
		for(int i = l + 1 ; i <= r ; i++)
			if(s[l] == s[i])
				ans = Math.min(ans, dp(l + 1, i - 1) + dp(i , r  ));
		
		return memo[l][r] = ans ; 
	}
	
	public static void main(String[] args) throws Exception 
	{
		Scanner sc = new Scanner(System.in) ; 
		PrintWriter out = new PrintWriter(System.out) ; 
		
		
		int n = sc.nextInt() ; 
		s = sc.next().toCharArray() ; 
		memo = new int [n][n] ; 
		
		for(int i = 0 ; i< n ; i++)
				Arrays.fill(memo[i], -1);
		
		out.println(dp(0, n - 1));
		out.flush();
		out.close(); 
	}

	static class Scanner 
	{
		BufferedReader br;
		StringTokenizer st;

		Scanner(InputStream in) 
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

		int nextInt() throws Exception { return Integer.parseInt(next()); }

		long nextLong() throws Exception { return Long.parseLong(next()); }

		double nextDouble() throws Exception { return Double.parseDouble(next());}

	}

	static void shuffle(int[] a) 
	{
		int n = a.length;
		for (int i = 0; i < n; i++) 
		{
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

}