시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 107 44 43 43.434%

문제

유명한 로직 게임 페그는 칩이 다른 칩을 점프해서 점프한 칩을 제거하는 게임이다. 게임은 보드판에 칩이 하나 남을 때 까지 계속한다.

아래 그림은 페그의 초기 상태이다.

  ooo
  ooo
ooooooo
ooo.ooo
ooooooo
  ooo
  ooo

그림에서 'o'는 칩을 나타내며, '.'는 빈 칸을 나타낸다. 플레이어가 칩 하나를 고른다. 그 다음에 고른 칩과 인접한 칸에 칩이 있고 그 다음 칸이 비어있다면, 그 칩을 뛰어넘고 뛰어넘은 칩을 보드판에서 제거한다. (방향은 위, 아래, 오른쪽 왼쪽 중 하나이다) 

보드의 상태가 주어졌을 대, 플레이어가 칩을 움직일 수 있는 올바른 방법의 수를 계산하는 프로그램을 작성하시오.

입력

총 일곱 줄에 걸쳐 보드의 상태가 주어진다. 처음 두 줄과 마지막 두 줄의 첫 번째, 두 번째 문자는 항상 공백이다. 나머지는 'o' 또는 '.'이다.

출력

첫째 줄에 올바른 이동의 수를 출력한다.

예제 입력 1

  ooo  
  ooo  
ooooooo
ooo.ooo
ooooooo
  ooo  
  ooo  

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjMwMTAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzOThcdWFkZjgiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzcyMFx1YmE4NVx1ZDU1YyBcdWI4NWNcdWM5YzEgXHVhYzhjXHVjNzg0IFx1ZDM5OFx1YWRmOFx1YjI5NCBcdWNlNjlcdWM3NzQgXHViMmU0XHViOTc4IFx1Y2U2OVx1Yzc0NCBcdWM4MTBcdWQ1MDRcdWQ1NzRcdWMxMWMgXHVjODEwXHVkNTA0XHVkNTVjIFx1Y2U2OVx1Yzc0NCBcdWM4MWNcdWFjNzBcdWQ1NThcdWIyOTQgXHVhYzhjXHVjNzg0XHVjNzc0XHViMmU0LiBcdWFjOGNcd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