from pprint import pprint

def iterate(h, w, board, max_height):
    count = 0
    for j in range(w):
        can_move = False
        for i in range(h - 1, max_height[j] - 1, -1):
            if board[i][j] == '.':
                can_move = True
            else:
                if can_move:
                    board[i + 1][j] = board[i][j]
                    board[i][j] = '.'
                else:
                    count += 1
                max_height[j] = i
    return count

def parse_input():
    h, w, n = list(map(int, input().split()))
    board = []
    for _ in range(h):
        board.append(list(input()))
    times = []
    for _ in range(n):
        times.append(int(input()))
    return h, w, n, board, times

def main():
    h, w, n, board, times = parse_input()
    t = max(times)
    answers = dict()
    max_height = [0] * w
    for i in range(t + 1):
        count = iterate(h, w, board, max_height)
        if i in times:
            answers[i] = count
    for t in times:
        print(answers[t])

if __name__ == "__main__":
    main()
