import math n, k = map(int, input().split(' ')) if n <= k**2: k = math.ceil(n**0.5) mod = n % k grid = ['#'*k for i in range(n//k)] if mod: grid.append(('#'*mod) + ('.'*(k-mod))) if len(grid) < k: grid.append('.'*k) else: l = math.ceil(n/k) mod = n % k grid = [('#'*k) + ('.'*(l-k)) for i in range(n//k)] if mod: grid.append(('#'*mod) + ('.'*(l-mod))) for i in range(1, len(grid)): grid[i] = grid[i][i:] + grid[i][:i] print(len(grid)) for row in grid: print(row)