시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 32 MB 13 8 4 44.444%

문제

Forsyth-Edwards 방식 체스에서는 다음과 같은 표기를 따른다.

  • 게임 내용은 왼쪽 상단부터 시작해서 오른쪽 하단까지 표시한다.
  • 문자 / 는 줄을 구분하기 위해 사용한다.
  • 각 줄은 왼쪽에서 오른쪽으로 표시한다.
  • 흰색 말은 영어 대문자로 다음과 같이 나타낸다 : PNBRQK
  • 검은색 말은 영어 소문자로 다음과 같이 나타낸다 : pnbrqk
  • 빈 칸은 1부터 8까지의 숫자로 나타낸다.
  • 숫자는 연속된 빈칸의 갯수를 뜻한다.
  • 각 행에서 숫자와 문자의 합은 반드시 8이다.

예를 들면,

  • 5k1r/2q3p1/p3p2p/1B3p1Q/n4P2/6P1/bbP2N1P/1K1RR3

은 아래의 체스판을 FEN으로 나타낸 것이다.

게임이 시작될 때 체스판은 아래와 같은 상태로 시작한다.

  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

우리가 해야할 일은, FEN으로 나타낸 체스판이 주어지면 어떤 말도 공격할 수 없는 빈 칸의 갯수를 세는 프로그램을 작성하는 것이다.

입력

여러 줄에 걸쳐, FEN로 표기한 체스판이 주어진다. 말의 위치는 임의로 정해진 것이므로 규칙에 어긋날 수 도 있다.

각 줄은 공백없이 주어진다.

출력

각 입력마다 어느곳으로도 공격받지 않는 빈칸의 갯수를 출력한다.

예제 입력 1

5k1r/2q3p1/p3p2p/1B3p1Q/n4P2/6P1/bbP2N1P/1K1RR3
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

예제 출력 1

3
16
W3sicHJvYmxlbV9pZCI6IjE2OTQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJGRU4gXHVjY2I0XHVjMmE0IiwiZGVzY3JpcHRpb24iOiI8cD5Gb3JzeXRoLUVkd2FyZHMgXHViYzI5XHVjMmRkIFx1Y2NiNFx1YzJhNFx1YzVkMFx1Y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