import heapq import math N,K = map(int,input().split()) M = max(-(-N//K),math.ceil(N**(1/2))) HW = [['.']*M for _ in range(M)] h = [] for i in range(M): h.append((0,i)) heapq.heapify(h) cnt = 0 for i in range(M): cnt0 = 0 while cnt0 != K: a,b = heapq.heappop(h) HW[i][b] = '#' heapq.heappush(h, (a+1,b)) cnt0 += 1 cnt += 1 if cnt == N: break if cnt == N: break print(M) for i in range(M): print(*HW[i],sep='')