N, K = map(int, input().split()) k = (N-1+K) // K if k < K: k = 0 while k**2 < N: k += 1 R = [['.']*(k) for i in range(k)] for i in range(k): for j in range(k): if N > 0: R[i][j] = '#' N -= 1 else: R = [['.']*(k) for i in range(k)] for i in range(k): for j in range(K*i, K*i+K): if N > 0: R[i][j % k] = '#' N -= 1 print(k) for line in R: print(*line, sep='')