import itertools from math import isqrt ceil = lambda a, b: (a + b - 1) // b ceil_sq = lambda n: 1 + isqrt(n - 1) N, K = map(int, input().split()) if N < K ** 2: M = ceil_sq(N) ans = [['.'] * M for _ in range(M)] for i, j in itertools.product(range(M), repeat=2): if i * M + j > N: break ans[i][j] = '#' else: M = ceil(N, K) ans = [['.'] * M for _ in range(M)] ct = 0 for i, j in itertools.product(range(M), repeat=2): if ct >= N: break if 0 <= (j - i) % M < K: ans[i][j] = '#' ct += 1 print(M) for a in ans: print(''.join(map(str, a)))