#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k;
  std::cin>>n>>k;

  ll row=n/k+((n%k==0)?0:1);

  while(row*row<n)row++;

  std::cout<<row<<"\n";

  ll cnt=0;

  rep(i,0,row){
    rep(j,0,row){
      if(((i+j)%row<k)&&(cnt<n)){
        std::cout<<'#';
        cnt++;
      }else{
        std::cout<<'.';
      }
    }
    std::cout<<"\n";
  }

  return 0;
}