A. Problemsolving Log

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Monocarp is participating in a programming contest, which features 2626 problems, named from 'A' to 'Z'. The problems are sorted by difficulty. Moreover, it's known that Monocarp can solve problem 'A' in 11 minute, problem 'B' in 22 minutes, ..., problem 'Z' in 2626 minutes.

After the contest, you discovered his contest log — a string, consisting of uppercase Latin letters, such that the i�-th letter tells which problem Monocarp was solving during the i�-th minute of the contest. If Monocarp had spent enough time in total on a problem to solve it, he solved it. Note that Monocarp could have been thinking about a problem after solving it.

Given Monocarp's contest log, calculate the number of problems he solved during the contest.

Input

The first line contains a single integer t� (1≤t≤1001≤�≤100) — the number of testcases.

The first line of each testcase contains a single integer n� (1≤n≤5001≤�≤500) — the duration of the contest, in minutes.

The second line contains a string of length exactly n�, consisting only of uppercase Latin letters, — Monocarp's contest log.

Output

For each testcase, print a single integer — the number of problems Monocarp solved during the contest.

Example

input

Copy


3

6

ACBCBC

7

AAAAFPC

22

FEADBBDFFEDFFFDHHHADCC

output

Copy

3
1
4

解题说明:此题是一道数学题,由于每个字母对应的解题时间是确定的,那么只需要统计解题日志中各个字母出现的次数,A至少出现1次,才代表解答了这一题,依次类推。B至少出现2次,C至少出现3次。遍历后统计字母出现的次数即可。

#include
int num[28];

int main()
{
	int t, i, n;
	scanf("%d", &t);
	char str[500];
	while (t--)
	{
		int cnt = 0;
		scanf("%d", &n);
		scanf("%s", str);
		for (i = 0; i < n; i++)
		{
			num[str[i] + 1 - 'A']++;
		}
		for (i = 1; i <= 26; i++)
		{
			if (num[i] >= i)
			{
				cnt++;
			}
			num[i] = 0;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

你可能感兴趣的:(AC路漫漫,算法)