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.*;
public class A
{
      static char c[];   static int dp[][];  static int n;
      public static void main(String ar[])
      {
            Scanner s=new Scanner(System.in);
            n=s.nextInt();  s.nextLine();
            c=s.nextLine().toCharArray();
            dp=new int[n][n];
            for(int a[]:dp)
            Arrays.fill(a,-1);
            int ans=got(0,n-1);
            System.out.println(ans);
            
      }
      
      public static int got(int a,int b)
      {
            if(a==b)
             return 1;
            if(dp[a][b]>=0)
             return dp[a][b];
            int ans=Integer.MAX_VALUE;
            if(a!=n-1 && c[a]==c[a+1])
              ans=Math.min(got(a+1,b),ans);
            if(b!=0 && c[b]==c[b-1])
              ans=Math.min(got(a,b-1),ans);
             for(int i=a;i<b;i++)
              ans=Math.min(ans,got(a,i)+got(i+1,b));
            for(int i=a+1;i<b;i++)
             if(c[a]==c[i+1])
               ans=Math.min(ans,got(a+1,i)+got(i+1,b));
            return dp[a][b]=ans;
      }
}