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:
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	   Scanner s=new Scanner(System.in);
	   int n=s.nextInt();
	   String str=s.next();
	   char[] a=str.toCharArray();
	   int[][] moves=new int[n][n];
	   int j=0;
	   
	   for(int l=0;l<n;l++)
	   {
	       for(int i=0;i<n-l;i++)
	       {
	            j=i+l;
	            moves[i][j]=MIN_MOVES(a,i,j,moves);
	            
	       }
	   }
	   
	   System.out.println(moves[0][n-1]);
	}
	
	public static int MIN_MOVES(char[] a,int i,int j,int[][] moves)
	{
	    int q;
	    if(i==j)
	     return 1;
	    else{
	        int min=moves[i][j-1]+1;
            int k=i;          	        
	        for(k=i;k<j;k++)
	        {
	            if(a[k]==a[j])
	            {
	               q=moves[i][k]+moves[k+1][j-1];
	               if(q<min)
	                 min=q;
	            }
	        }
	      return min;
	    }
	   
	}
}