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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) throws IOException {
        BufferedWriter bw = new BufferedWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        InputReader ir = new InputReader(System.in);
        new Solution(bw,ir);
    }

    public Solution(BufferedWriter bw, InputReader ir) throws IOException {
        int n = ir.nextInt();
        char[] arr = ir.next().toCharArray();
        ArrayList<Character> al = new ArrayList<>();
        int ind = 0;
        al.add(arr[ind]);
        while (ind < n){
            int cur = ind+1;
            while (cur<n && arr[ind] == arr[cur])
                cur++;
            if (cur<n){
                al.add(arr[cur]);
            }
            ind = cur;
        }
        n = al.size();
        int[][] dp = new int[n+1][n+1];

        for (int len = 1; len<=n; ++len){
            for (int i=0, j = len -1; j<n; ++i, ++j){
                if (len == 1)
                    dp[i][j] = 1;
                else {
                    dp[i][j] = 1 + dp[i+1][j];
                    for (int k=i+2; k<=j; ++k){
                        dp[i][j] = Math.min(dp[i][j],dp[i][k]+(k<j?dp[k+1][j]:0));
                    }
                    if (al.get(j) == al.get(i)){
                        for (int k=i+2; k<j; ++k){
                            if (al.get(i) == al.get(k))
                                dp[i][j] = Math.min(dp[i][j],dp[i][k]+dp[k][j]-1);
                        }
                        dp[i][j] = Math.min(dp[i][j],dp[i+1][j-1]+1);
                    }
                }
            }
        }
        System.out.println(dp[0][n-1]);
        bw.flush();
        bw.close();
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}