Fellow me on GitHub

CodeForces757A

A. Gotta Catch Em' All!

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbasaur.

Each day, he takes the front page of the newspaper. He cuts out the letters one at a time, from anywhere on the front page of the newspaper to form the word "Bulbasaur" (without quotes) and sticks it on his wall. Bash is very particular about case — the first letter of "Bulbasaur" must be upper case and the rest must be lower case. By doing this he thinks he has caught one Bulbasaur. He then repeats this step on the left over part of the newspaper. He keeps doing this until it is not possible to form the word "Bulbasaur" from the newspaper.

Given the text on the front page of the newspaper, can you tell how many Bulbasaurs he will catch today?

Note: uppercase and lowercase letters are considered different.

Input

Input contains a single line containing a string s (1  ≤  |s|  ≤  105) — the text on the front page of the newspaper without spaces and punctuation marks. |s| is the length of the string s.

The string s contains lowercase and uppercase English letters, i.e. .

Output

Output a single integer, the answer to the problem.

Examples

input

Bulbbasaur

output

1

input

F

output

0

input

aBddulbasaurrgndgbualdBdsagaurrgndbb

output

2

Note

In the first case, you could pick: Bulbbasaur.

In the second case, there is no way to pick even a single Bulbasaur.

In the third case, you can rearrange the string to BulbasaurBulbasauraddrgndgddgargndbb to get two words "Bulbasaur".

 

 

 1 //2017.01.18
 2 #include <iostream>
 3 #include <cstdio>
 4 #include <cstring>
 5 
 6 using namespace std;
 7 
 8 const int inf = 0x3f3f3f3f;
 9 int book[100];
10 
11 int main()
12 {
13     string str;
14     string bul = "Bulbbasaur";
15     while(cin >> str)
16     {
17         memset(book, 0, sizeof(book));
18         for(int i = 0; i < str.length(); i++)
19               book[str[i]]++;
20         book['u']/=2;
21         book['a']/=2;
22         int ans = inf;
23         for(int i = 0; i < bul.length(); i++)
24               if(ans > book[bul[i]])
25                   ans = book[bul[i]];
26         cout<<ans<<endl;
27     }
28 
29     return 0;
30 }

 

posted @ 2017-01-18 20:53  Penn000  阅读(273)  评论(0编辑  收藏  举报