N, K = map(int, input().split()) M = (N + (K - 1)) // K if M < K: from math import sqrt n = int(sqrt(N)) if n * n < N: n += 1 M = n lst = [['.'] * M for _ in range(M)] for i in range(M): for j in range(M): if N > 0: lst[i][j] = '#' N -= 1 print (M) for i in lst: print (*i, sep = '') exit() 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 = '')