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
 //package Codeforces;
import java.util.*;
import java.awt.List;
import java.io.*;
public class D
{
   static final int mod = (int) 1e9 + 7;
   static final int inf = (int) 1e9;
   static final long INF = (long) 1e18;
   static int n;static char arr[]=new char[501];
   static int dp[][]=new int[501][501];
   public static void main(String[] args) throws IOException 
   {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		n=fs.nextInt();
		String str=fs.next();
		for(int i=1;i<=n;i++)arr[i]=str.charAt(i-1);
		fill();
		out.println(solve(1,n));out.close();
   }
   public static int solve(int left,int right)
   {
	  if(left>right)return 0;
	  if(left==right)return 1;
	  if(dp[left][right]!=-1)return dp[left][right];
	  int ans=1+solve(left+1,right);
	  for(int idx=left+1;idx<=right;idx++)
	  {
		  if(arr[idx]==arr[left])
			  ans=Math.min(ans,solve(left+1,idx-1)+solve(idx,right));
	  }
	  return dp[left][right]=ans;
   }
   public static void fill()
   {
	   for(int i=0;i<dp.length;i++)Arrays.fill(dp[i],-1);
   }
	public static int upper_bound(int arr[],int key)
	{
		int index=inf,num=0;
		int left=0,right=arr.length-1;
		while(left<=right)
		{
			int mid=left+(right-left)/2;
			if(arr[mid]<=key) {index=mid;num=arr[mid];left=mid+1;}
			else 
				right=mid-1;
		}
		return index==inf ? arr.length:index;
	}
}
class FastScanner {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer("");

	public String next() {
		while (!st.hasMoreTokens())
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		return st.nextToken();

	}

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

	int[] sort(int arr[]) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i : arr)
			list.add(i);
		Collections.sort(list);
		for (int i = 0; i < arr.length; i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

	char[] charsort(char arr[]) {
		ArrayList<Character> list = new ArrayList<>();
		for (char c : arr)
			list.add(c);
		Collections.sort(list);
		for (int i = 0; i < list.size(); i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

	long[] longsort(long arr[]) {
		ArrayList<Long> list = new ArrayList<Long>();
		for (long i : arr)
			list.add(i);
		Collections.sort(list);
		for (int i = 0; i < arr.length; i++) {
			arr[i] = list.get(i);
		}
		return arr;
	}

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

	public int[] readArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextInt();
		return arr;
	}

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

	public long[] longreadArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}
