n,k = map(int,input().split()) cdd = (n+(k-1))//k f = False if cdd < k: tmp = cdd while tmp**2 < n: tmp += 1 m = tmp f = True else: m = cdd print(m) ans = [[""]*m for i in range(m)] if f == True: cnt = n for i in range(m): for j in range(m): if cnt > 0: cnt -= 1 ans[i][j] = "#" else: ans[i][j] = "." else: cnt = n for i in range(m): lm = k for j in range(m): if cnt > 0 and lm > 0: cnt -= 1 lm -= 1 ans[i][(j+i)%m] = "#" else: ans[i][(j+i)%m] = "." for i in range(m): print(*ans[i],sep="")