import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, K = map(int,read().split()) def f(n, K): """n*n のグリッドに配置できる最大個数""" if K > n: K = n return n * K def make_grid(n, K, N): if K > n: K = n x, y = np.meshgrid(np.arange(n), np.arange(n)) I, J = np.where((x + y) % n < K) I = I[:N] J = J[:N] A = np.full((n,n), '.') A[I,J] = '#' return A for n in range(1, N+10): if f(n, K) >= N: break A = make_grid(n, K, N) print(n) print('\n'.join(''.join(row) for row in A))