N, K = map(int, input().split()) M = (N + (K - 1)) // K lst = [['.'] * M for _ in range(M)] for i in range(M): for j in range(K): if N > 0: lst[i][(i + j) % M] = '#' N -= 1 else: break print (M) for i in lst: print (*i, sep = '')