시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 57 27 26 57.778%

문제

가위 바위 보는 두 사람이 즐기는 유명한 게임이다. 각 플레이어는 자신의 손을 이용해서 가위, 바위, 보 중 한 모양을 만들어야 한다. 두 플레이어가 같은 모양을 만든 경우에는 비기게 된다. 가위는 보를 이기고, 보는 바위, 바위는 가위를 이긴다.

상근이는 사람들의 심리를 수십년동안 연구한 결과 가위 바위 보를 한국에서 가장 잘 하는 사람이 되었다. 상근이는 일대일 가위 바위 보를 절대로 지지 않는다.

한국에 적수가 없다고 판단한 상근이는 세계 대회에 나가기로 했다. 요즘 상근이는 세계 대회를 대비해 훈련중이다. 훈련은 친구 N명과 동시에 한다. 가위바위보는 총 R개의 라운드로 이루어져 있고, 각 라운드마다 상근이와 친구들은 세 모양중 하나를 만들어야 한다.

각 라운드의 점수 계산은 상근이와 친구 개개인을 독립적으로 비교한다. 상근이가 이기면 2점, 비기면 1점, 지면 0점이다. 

상근이와 친구들이 각 라운드에 낸 모양이 주어졌을 때, 게임이 끝나고 난 후 상근이의 점수를 구한다. 그 다음, 상근이가 친구들이 무엇을 낼지 미리 알고있었다고 가정할 때, 상근이가 얻을 수 있는 최고 점수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 라운드 수 R (1 ≤ R ≤ 50)이 주어진다.

둘째 줄에는 상근이가 각 라운드에 낸 모양이 주어진다. S는 가위, P는 보, R은 바위이다.

셋째 줄에는 친구의 수 N (1 ≤ N ≤ 50)이 주어진다.

다음 N개 줄에는 상근이의 친구들이 각 라운드에 낸 모양이 주어지며, 한 줄에 한 명씩 주어진다.

출력

첫째 줄에 상근이의 점수를 출력한다.

둘째 줄에는 상근이가 얻을 수 있는 최대 점수를 출력한다.

예제 입력 1

5
SSPPR
1
SSPPR

예제 출력 1

5
10
W3sicHJvYmxlbV9pZCI6IjI5MzAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjMDBcdWM3MDQgXHViYzE0XH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