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.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.CollationKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.crypto.spec.GCMParameterSpec;

public class baba {
	public static class edge implements Comparable<edge> {
		int u;
		int v;

		public edge(int u, int v) {
			this.u = u;
			this.v = v;
		}

		@Override
		public int compareTo(edge e) {

			return u - e.u;
		}
	}

	static char[] Arr;
	static int[][] memo;

	public static long gcd(long u, long v) {
		if (u == 0)
			return v;
		return gcd(v % u, u);
	}

	static PrintWriter pw;

	public static int dp(int u, int v) {
		if (u > v)
			return 0;
		if (memo[u][v] != -1)
			return memo[u][v];
		int min = (int) 1e9;
		min = Math.min(dp(u + 1, v) + 1, dp(u, v - 1) + 1);
		int start0 = 0;
		int start1 = 0;
		if (Arr[u] == Arr[v])
			for (int i = u; i < v + 1; i++) {
				if (Arr[i] == Arr[u]) {
					start0 += dp(u + 1, i - 1);
					min = Math.min(min, start0 + dp(i + 1, v));
					min = Math.min(min, dp(u + 1, i - 1) + dp(i + 1, v)) + 1;
				}
				if (Arr[i] == Arr[v]) {
					start1 += dp(u, i - 1);
					min = Math.min(min, start1 + dp(i + 1, v - 1));
					min = Math.min(min, dp(u, i - 1) + dp(i + 1, v - 1)) + 1;
				}
			}
		return memo[u][v] = min;
	}

	public static int dp2(int u, int v) {
		if (u > v)
			return 0;
		if (memo[u][v] != -1)
			return memo[u][v];
		
		int min = dp2(u + 1, v) + 1;
		for (int i = u+1; i < v + 1; i++)
			if (Arr[i] == Arr[u])
				min = Math.min(min, dp2(u + 1, i - 1) + dp2(i, v));
		
		return memo[u][v] = min;
	}

	public static void main(String[] args) throws IOException, InterruptedException {
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		Arr = str.toCharArray();
		memo = new int[n][n];
		for (int[] x : memo)
			Arrays.fill(x, -1);
		System.out.println(dp2(0, n - 1));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}