N, K = map(int, input().split()) k = (N-1+K) // K 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='')