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
{
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static class Pair implements Comparable<Pair>
    {
        int f,s;
        Pair(int f,int s)
        {
            this.f=f;
            this.s=s;
        }
        public int compareTo(Pair p)
        {
            return this.s-p.s;
        }
    }
    static long pow(long a,int p,long mod)
    {
        long res=1;
        while(p>0)
        {
            if(p%2==1)
            {
                p--;
                res=res*a;
                res%=mod;
            }
            else
            {
                a*=a;
                a%=mod;
                p/=2;
            }
        }
        return res;
    }
    public static void main(String args[])
    {
        FastReader fs=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int n=fs.nextInt();
        char c[]=fs.nextLine().toCharArray();
        int a[][]=new int[n+1][n+1];
        for(int i=1;i<=n;i++)
        a[i][i]=1;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=n-i+1;j++)
            {
                int min=Integer.MAX_VALUE;
                for(int k=j+i-2;k>=j;k--)
                {
                    if(c[j+i-2]==c[k-1])
                    {
                        int temp=0;
                        if(k+1<=j+i-2)
                        temp=a[k+1][j+i-2];
                        min=Math.min(min,temp+a[j][k]);
                    }
                    else
                    {
                        int temp=a[j][k];
                        if(k+1<j+i-1)
                        temp+=a[k+1][j+i-2];
                        min=Math.min(temp+1,min);
                    }
                }
                a[j][j+i-1]=min;
            }
        }
        pw.println(a[1][n]);
        pw.flush();
        pw.close();
    }
}