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.sql.Array;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class MainS {
    static final long MOD = 999998693, INF = 1_000_000_000_000_000_000L,BASE = 31;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 100000000);
        t.start();
    }
    static class O implements Runnable {
        public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    public 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 int n, dp[][][],N;
    static char c[];
    static void magic() throws IOException {
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        n = reader.nextInt();
        dp = new int[n][n][26];
        c = new char[n];
        for(int i=0;i<n;++i) {
            for(int j=0;j<n;++j) {
                for(int k=0;k<26;++k) {
                    dp[i][j][k] = -1;
                }
            }
        }
        N = 0;
        String s = reader.next();
        for(int i=0;i<n;++i) {
            while(i+1<n && s.charAt(i+1)==s.charAt(i)) {
                i++;
            }
            c[N++] = s.charAt(i);
        }
//        writer.println("new size : "+N);
//        for(char cc : c) {
//            writer.print(cc+" ");
//        }
//        writer.println();
        int min = Integer.MAX_VALUE;
        for(int i=0;i<26;++i) {
            min = min(min, f(0, N-1, i)+1);
        }
        writer.println(min);
    }
    static int f(int l, int r,int rem_char) {
        if(l>r) {
            return 0;
        }
        if(l==r) {
            if(rem_char==(c[l]-'a')) {
                return 0;
            }
            return 1;
        }
        if(dp[l][r][rem_char]!=-1) {
            return dp[l][r][rem_char];
        }
        int min = Integer.MAX_VALUE;
        for(int i=l;i<=r;++i) {
            if((c[i]-'a')==rem_char) {
                min = min(min, f(l, i-1, rem_char) + f(i+1, r, rem_char));
            }
            else {
                min = min(min, 1+f(l, i-1, (c[i]-'a')) + f(i+1, r, (c[i]-'a')));
            }
        }
        return dp[l][r][rem_char] = min;
    }
}