public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			solve = 0;
			n = scan.nextInt();
			k = scan.nextInt();
			scan.nextLine();
			if(n == -1 && k == -1)
				break;
			visit = new boolean[n];
			Arrays.fill(visit, false);
			chess = new boolean[n][n];
			for(int i=0;i<n;i++){
				String line = scan.nextLine();
				for(int j=0;j<n;j++){
					chess[i][j] = line.charAt(j)=='#'?true:false;
				}
			}
			if(k>n){
				System.out.println(0);
				continue;
			}
//			for(int i=0;i<n;i++){
//				func(i, 1);
//			}
			func(-1, 0);
			System.out.println(solve);
		}
	}