#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 #A def A(): a,b = LI() for i in range(1,101): if a%i == 0 and i%b == 0: print("YES") return print("NO") return #B def B(): n,k = LI() p = n//(k**2) n_ = n-p*k**2 for k_ in range(100000): if k_**2 >= n_:break h = p*k+k_ s = [] l = 0 r = k for i in range(p): for j in range(k): s.append(["#" if l <= i < r else "." for i in range(h)]) l,r = r,r+k for j in range(k_): s.append(["#" if l <= i < r else "." for i in range(h)]) su = p*k**2+k_**2 for i in range(p*k,h)[::-1]: if su == n: break s[-1][i] = "." su -= 1 for i in range(p*k,h-1)[::-1]: if su == n: break s[i][-1] = "." su -= 1 print(h) for i in s: print(*i,sep = "") return #C def C(): return #D def D(): return #E def E(): return #F def F(): return #Solve if __name__ == "__main__": B()