N, K = map(int, input().split()) k = (N-1+K) // K R = [['.']*k for i in range(k)] for i in range(k): for j in range(K*i, K*i+K): R[i][j % k] = '#' print(k) for line in R: print(*line, sep='')