import numpy N,K=map(int,input().split()) a=(N//(K*K)) b=0 if N<=K*K: a=0 b=int(numpy.sqrt(N-1/2)+1) elif not N%(K*K)==0: b=int(numpy.sqrt(N%(K*K)-1/2))+1 M=a*K+b print(M) for i in range(a): word='.'*(i*K)+'#'*K+'.'*(M-K*(i+1)) for j in range(K): print(word) last=N-K*K*a for j in range(b): num=0 if last>=b: last=last-b num=b elif last>0: num=last last=0 word='.'*(a*K)+'#'*num+'.'*(M-a*K-num) print(word)