cho.sh
Notes
Loading...

Chessboard in FEN

Time limit

1s

Memory limit

32 MB

Problem

FEN (Forsyth-Edwards Notation) describes the contents of a chessboard in one line.

  • The board contents are written from the top row to the bottom row.
  • Adjacent rows are separated by the / character.
  • Each row is written from left to right.
  • White pieces are written with uppercase letters: PNBRQK.
  • Black pieces are written with lowercase letters: pnbrqk.
  • Empty squares are written with digits from 1 through 8.
  • A digit means that many consecutive empty squares in that row.
  • In every row, the total number of squares represented by digits and piece letters is exactly 8.

You are given one chessboard description per line. The described position does not have to be legal under chess rules. For each board, compute how many squares are empty and are not attacked by any piece.

Input

The input consists of several lines. Each line contains one FEN description of a chessboard. Input lines contain no whitespace.

Output

For each input line, output one integer on its own line: the number of empty squares that are not attacked by any piece.