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.io.*;
import java.util.*;

/** Clear the string **/

public class F {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    private static class Solver {

        private StringBuilder s;
        private int[][] dp;

        private int min(int a, int b) {
            return a > b ? b : a;
        }

        private int count(int l, int r) {
            if (dp[l][r] != -1) return dp[l][r];
            if (l == r) return dp[l][r] = 1;

            int cnt = 1 + count(l + 1, r);
            for (int i = l + 1; i <= r; i++) {
                if (s.charAt(i) == s.charAt(l)) {
                    cnt = min(cnt, count(l + 1, i - 1) + count(i, r));
                }
            }
            return dp[l][r] = cnt;
        }

        private void solve(InputReader in, PrintWriter out) {
            in.nextInt();
            s = new StringBuilder(in.next());

            for (int i = 1; i < s.length(); i++) {
                if (s.charAt(i - 1) == s.charAt(i))
                    s.deleteCharAt(i--);
            }

            int n = s.length();
            dp = new int[n][n];
            for (int i = 0; i < n; i++)
                Arrays.fill(dp[i], -1);

            out.println(count(0, n - 1));
        }
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

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

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

        private double nextDouble() {
            return Double.parseDouble(next());
        }

        private String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    }
}