res = 0
def main():
while True:
global res
res = 0
n, k = map(int, input().split())
if n == -1:
break
board = [[0] * n for i in range(n)]
cols = [0] * n
for i in range(n):
row = list(input())
for j in range(len(row)):
board[i][j] = row[j]
dfs(n, k, 0, 0, board, cols)
print(res)
def dfs(n , k, row, num, board, cols):
'''
row: 第几行
num: 已经放了几个棋子
'''
global res
if num == k:
res += 1
return
if row == n:
return
dfs(n, k, row + 1, num, board, cols)
for i in range(n):
if board[row][i] == '.' or cols[i]:
continue
cols[i] = True
dfs(n, k, row + 1, num + 1, board, cols)
cols[i] = False
main()