eolymp
bolt
Try our new interface for solving problems
Problems

Chessboard in FEN

Chessboard in FEN

In the FEN (Forsyth-Edwards Notation), a chessboard is described as follows: \begin{itemize} \item The Board-Content is specified starting with the top row and ending with the bottom row. \item Character / is used to separate data of adjacent rows. \item Each row is specified from left to right. \item White pieces are identified by uppercase piece letters: \textbf{PNBRQK}. \item Black pieces are identified by lowercase piece letters: pnbrqk. \item Empty squares are represented by the numbers one through eight. \item A number used represents the count of contiguous empty squares along a row. \item Each row's sum of numbers and characters must equal \textbf{8}. \end{itemize} For example: \textbf{5k1r/2q3p1/p3p2p/1B3p1Q/n4P2/6P1/bbP2N1P/1K1RR3} is the FEN notation description of the following chessboard: \includegraphics{https://static.e-olymp.com/content/ed/ed15a276bbe741311a534137d1b4d63c9ad4ef31.jpg} The chessboard of the beginning of a chess game is described in FEN as: \textbf{rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR} Your task is simple: given a chessboard description in a FEN notation you are asked to compute the number of unoccupied squares on the board which are not attacked by any piece. \InputFile Input is a sequence of lines, each line containing a FEN description of a chessboard. Note that the description does not necessarily give a legal chess position. Input lines do not contain whitespace. \OutputFile For each line of input, output one line containing an integer which gives the number of unoccupied squares which are not attacked.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5k1r/2q3p1/p3p2p/1B3p1Q/n4P2/6P1/bbP2N1P/1K1RR3
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
Output example #1
3
16