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

// Imports
import java.util.*;
import java.io.*;

public class F1132 {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException 
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {
        
        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        
        
        // TODO code application logic here
        int N = Integer.parseInt(f.readLine());
        String s = f.readLine();
        
        // int[][] dp
        // dp[i][j][k] where i is the length, j is the starting position, and k is the last letter to get deleted
        int[][] dp = new int[N + 1][N];
        
        for(int l = 0; l < N; l++) {
            dp[1][l] = 1;
        }
        
        for(int len = 2; len <= N; len++) {
            for(int start = 0; start <= N - len; start++) {
                // System.out.println(start);
                dp[len][start] = 1 + dp[len - 1][start + 1];
                
                for(int k = 1; k < len; k++) {
                    if(s.charAt(start + k) == s.charAt(start)) {
                        // System.out.println(start + " " + k);
                        dp[len][start] = Math.min(dp[len][start], dp[k - 1][start + 1] + dp[len - k][start + k]);
                    }
                }
            }
        }
        
        System.out.println(dp[N][0]);
        
    }

}
