n,k = map(int, input().split()) t = n//(k**2) m = n - t*k*k if not m: print(t) for i in range(t*k): v = '.'*i*k + '#'*k + '.'*(t-1-i)*k for j in range(k): print(v) else: d = int((m-.5)**.5) + 1 print(t*k+d) for i in range(t): v = '.'*i*k + '#'*k + '.'*((t-1-i)*k + d) for j in range(k): print(v) v = '.'*t*k + '#'*d for i in range(d): if m > d: print(v) m -= d else: print('.'*(t*k + d - m) + '#'*m) m -= m