Algorithm


B. ICPC Balloons
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In an ICPC contest, balloons are distributed as follows:

  • Whenever a team solves a problem, that team gets a balloon.
  • The first team to solve a problem gets an additional balloon.
A contest has 26 problems, labelled AABBCC, ..., ZZ. You are given the order of solved problems in the contest, denoted as a string s, where the i-th character indicates that the problem si�� has been solved by some team. No team will solve the same problem twice.

Determine the total number of balloons that the teams received. Note that some problems may be solved by none of the teams.

Input

The first line of the input contains an integer t (1t1001≤�≤100) — the number of testcases.

The first line of each test case contains an integer n (1n501≤�≤50) — the length of the string.

The second line of each test case contains a string s of length n consisting of uppercase English letters, denoting the order of solved problems.

Output

For each test case, output a single integer — the total number of balloons that the teams received.

Example
input
Copy
6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES
output
Copy
5
2
6
7
8
17
Note

In the first test case, 55 balloons are given out:

  • Problem AA is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem AA.
  • Problem BB is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem BB.
  • Problem AA is solved. That team receives only 11 balloon, because they solved the problem. Note that they don't get an additional balloon because they are not the first team to solve problem AA.
The total number of balloons given out is 2+2+1=52+2+1=5.

In the second test case, there is only one problem solved. The team who solved it receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem AA.

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    string s;
    cin>>s;
    unordered_set<char> uos;
    for(char c : s){
      uos.insert(c);
    }
    cout<<n+uos.size()<<endl;
  }

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES

Output

x
+
cmd
5
2
6
7
8
17
Advertisements

Demonstration


Codeforcess Solution 1703-B B. ICPC Balloons ,C++, Java, Js and Python,1703-B,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+