from math import sqrt N, K = map(int, input().split()) if N <= K: M = int(sqrt(N)) if M * M < N: M += 1 print (M) for i in range(M): for j in range(M): if N > 0: print ('#', end = '') N -= 1 else: print ('.', end= '') print() exit() count = N // (K * K) N -= count * K * K #残り塗らないといけない枚数 n = (N + (K - 1)) // K M = count * K + n lst = [['.'] * M for _ in range(M)] for i in range(count * K): for j in range(count * K): if i // K == j // K: lst[i][j] = '#' for i in range(count * K, M): for j in range(count * K, M): if n > 0: lst[i][j] = '#' n -= 1 else: break print (M) for i in lst: print (*i, sep = '')