Winning the Vote

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

In the country of Elecuador, a very strange voting system is used. When it is time for the election, each one of the nn citizens will arrive in some order to the voting station.  There are only two parties to vote for, conveniently named 11 and 22. When arriving to the voting station, a person will vote for one of the parties, unless they are a teller. The tellers do not vote, instead they count how many votes each of the two parties has at the time the teller arrives, and if one of the parties has more votes than the other then that party receives one point (if the two parties have the same number of votes, neither of them receives a point). The party with the most points at the end wins. If both parties end up with the same number of points, chaos ensues.

As the president of Elecuador representing party 11, you are worried that the coming election will be the end of your reign. Fortunately, you have a plan to stop this from happening.  Being the president, you know who everyone in the country will vote for, who the tellers are, and in what order everyone will arrive to the voting station. By making the right phone calls, you can also affect when the tellers arrive. In one move, it is possible to swap a teller with an adjacent person in the list of arrivals to the voting station. Note that it is not possible to swap two adjacent non-tellers. What is the minimum number of swaps necessary to ensure that party 11 wins?

입력

The input starts with a line containing an integer nn nn (1n5,0001 \le n \le 5\\,000), the number of citizens in Elecuador. Then follows a line containing a string ss of length nn, consisting of the characters 00, 11, and 22. This string represents the citizens in the order they arrive to the voting station. If the ii'th character s_is\_i is 11 or 22, it means that the ii'th citizen will vote for party 11 or 22, respectively. If s_is\_i is 00, it means that the ii'th citizen is a teller.

출력

If it is possible to ensure victory, output one integer, the minimum number of swaps necessary. Otherwise, output "impossible".