rr = raw_input rri = lambda: int(raw_input()) rrm = lambda: map(int, raw_input().split()) def make(N, K, tot): otot = tot ans = [['.'] * N for _ in xrange(N)] for r, row in enumerate(ans): for c, v in enumerate(row): zr = r / K zc = c / K if zr == zc and tot: ans[r][c] = '#' tot -= 1 if tot: return make(N+1, K, otot) return ans def solve(tot, K): # tot - total #'s # K - max #'s per row/col q,r = divmod(tot, K) N = q + (r > 0) return make(N, K, tot) ans = solve(*rrm()) print len(ans) for row in ans: print "".join(row)