main :: IO ()
main = do
  firstRow <- getLine
  print . length
        . filter (=='.')
        . concat
        . take 40 $ iterate nextRow firstRow

nextRow :: String -> String
nextRow row = map rule (zip3 left center right)
  where
    left   = '.' : init row
    center = row
    right  = tail row ++ "."
    rule ('^', '^', '.') = '^'
    rule ('.', '^', '^') = '^'
    rule ('^', '.', '.') = '^'
    rule ('.', '.', '^') = '^'
    rule (_, _, _)       = '.'
