Students in Railway Carriage
Contest: Educational Codeforces Round 42 (Rated for Div. 2)
Difficulty rating: 1300
Tags: constructive algorithms, greedy, implementation

There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.

The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the railway carriage so that:

- no student-programmer is sitting next to the student-programmer;
- and no student-athlete is sitting next to the student-athlete.

In the other words, there should not be two consecutive (adjacent) places where two student-athletes or two student-programmers are sitting.

Consider that initially occupied seat places are occupied by jury members (who obviously are not students at all).

Input format:
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b > 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes.

The second line contains a string with length $$$n$$$, consisting of characters "." and "*". The dot means that the corresponding place is empty. The asterisk means that the corresponding place is occupied by the jury member.

Output format:
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.

Constraints:
Time limit: 2.0 s
Memory limit: 256.0 MB

Note:
In the first example you can put all student, for example, in the following way: *.AB*

In the second example you can put four students, for example, in the following way: *BAB*B

In the third example you can put seven students, for example, in the following way: B*ABAB**A*B

The letter A means a student-programmer, and the letter B — student-athlete.

Example input:
5 1 1
*...*

Example output:
2

Example input:
6 2 3
*...*.

Example output:
4

Editorial:
We will iterate from the left to the right through the given string and take the maximal substrings consisting from the dots only (bounded by asterisks/string bounds). Let the length of the current such substring is $$$len$$$.
If $$$len$$$ is even, in the places corresponding to this substring, you can put maximum $$$len / 2$$$ students of each type, simply alternating them. Considering remaining $$$a$$$ and $$$b$$$, you can put $$$\min(a, len / 2)$$$ student-programmers and $$$\min(b, len / 2)$$$ student-athletes in these places.
If $$$len$$$ is odd, then in the places corresponding to this substring, you can put $$$(len + 1) / 2$$$ students of the one type and $$$len / 2$$$ students of the other type. If $$$a > b$$$, then you need to start put students from a student-programmer. So, $$$\ min(a, (len + 1) / 2)$$$ of student-programmers and $$$\ min(b, len / 2)$$$ of student-athletes can be put in this substring. Otherwise, you need to put students in the same way, but starting from a student-athlete.
Also, you need to remember to maintain the number of remaining students $$$a$$$ and $$$b$$$ after processing the current substring and move on to the next substring consisting of the dots only.