n, k = map(int, input().split()) if n <= k**2: for i in range(1, k + 1): if i**2 >= n: ANS = [['#' for _ in range(i)] for _ in range(i)] if i**2 > n: cnt = i**2 for j in range(i): for jj in range(i): ANS[j][jj] = '.' cnt -= 1 if cnt == n: break if cnt == n: break break else: for i in range(k + 1, n + 1): if k * i >= n: ANS = [['.' for _ in range(i)] for _ in range(i)] for j in range(i): for jj in range(j, j + k): ANS[j][jj % i] = '#' if k * i > n: cnt = k * i for j in range(i): for jj in range(j, j + k): ANS[j][jj] = '.' cnt -= 1 if cnt == n: break if cnt == n: break break h = len(ANS) print(h) for i in range(h): print(''.join(ANS[i]))