from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
W = math.ceil(max(N/K,math.sqrt(N)))

MAP = [['.']*W for _ in range(W)]

x = y = 0
k = 0
for _ in range(N):
    MAP[y][x] = '#'
    if k>0 and k%W == W-1:
        x += 1
    else:
        x += 1
        y += 1
    x %= W
    y %= W
    k += 1

print(W)
print('\n'.join([''.join(m) for m in MAP]))