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.util.*;
public class HelloWorld{
    
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;
 
        InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        int nextInt() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        long nextLong() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        String readString() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        String nextLine() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(c));
            return res.toString();
        }
 
        boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);
        }
    }

    public static void main(String []args){
    
        InputReader sc = new InputReader(System.in);
        
        int n = sc.nextInt();
        
        String str = sc.readString();
        str = reduce(str);
        n = str.length();
        
        int dp[][] = new int[n][n];
        
        for(int len=0; len<n; len++){
            for(int begin=0; begin+len<n; begin++){
                int end = begin + len;
                
                if(len == 0){
                    dp[begin][end] = 1;
                    continue;
                }
                
                dp[begin][end] = 1 + dp[begin+1][end];
                
                for(int i=begin+1; i<=end; i++){
                    if(str.charAt(begin) == str.charAt(i))
                        dp[begin][end] = Math.min(dp[begin][end], dp[begin+1][i-1] + dp[i][end]);
                }
            }
        }
        
        System.out.println(dp[0][n-1]);
    }
    
    private static String reduce(String str){
        StringBuffer stringBuffer = new StringBuffer("");
        
        stringBuffer.append(str.charAt(0));
        
        for(int i=1; i<str.length(); i++){
            if(str.charAt(i) != str.charAt(i-1))
                stringBuffer.append(str.charAt(i));
        }
        
        return stringBuffer.toString();
    }
}