Problem A: Advantage

Xem dạng PDF

Gửi bài giải

Điểm: 1,00
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Tác giả:
Dạng bài

Trong trường hợp đề bài hiển thị không chính xác, bạn có thể tải đề bài tại đây: Đề bài

Luna and Tina are two final-year IT students at UMT University. In their free time, they came up with the idea of creating a game that simulates the familiar rock-paper-scissors game. This is a strategic game where two players compete against each other using a special deck of cards. The deck consists of ~2n~ cards, divided into three types: rock, paper, and scissors.

Problem A

Each player is dealt ~n~ cards, and the game proceeds as follows:

• The game consists of ~n~ rounds, and in each round, both players will choose a card from their hand and compare them according to the rules: rock beats scissors, scissors beats paper, and paper beats rock.

• After comparison, if the two cards are equal, neither player scores a point. If one card wins, that player scores 1 point.

• The used card cannot be used again in subsequent rounds.

After developing the game, Luna and Tina decided to test it to find any bugs before release. During the testing, Luna accidentally discovered that he could see the card Tina would choose in each round. Before informing Tina so they could fix the bug together, Luna wanted to surprise Tina with his luck. Therefore, Luna secretly exploited this bug to achieve an overwhelming victory over Tina.

Calculate the maximum point difference between Luna and Tina when the game ends.


Input

The first line is the integer ~n~ ~(1 ≤ n ≤ 10^6)~.

The second line contains ~n~ characters separated by spaces, representing Luna's cards.

The third line contains ~n~ characters separated by spaces, representing Tina's cards.

The second and third lines contain only the characters R, S, and P, corresponding to rock, scissors, and paper, respectively.


Output

A single integer is the maximum point difference between Luna and Tina.


Sample Input 1

3
R P S
P P P

Sample Ouput 1

0

Note

Luna's optimal play strategy:

• Tina chooses the first card P, Luna will choose the card R. Luna loses, so Tina gets 1 point.

• Tina chooses the second card P, Luna will choose the card P. It's a tie, so no one gets any points.

• Tina chooses the last card P, Luna will choose the card S. Luna wins, so Luna gets 1 point.

Thus, the point difference is 1 - 1 = 0.


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.