import sys readline=sys.stdin.readline N,K=map(int,readline().split()) H=max((N+K-1)//K,int((N-1)**.5)+1) K=min(K,H) ans_lst=[["."]*H for h in range(H)] for i in range(H): for j in range(i,i+K): if N: ans_lst[i][j%H]="#" N-=1 print(H) for ans in ans_lst: print(*ans,sep="")