#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define vi vector<ll>
#define vii vector<vector<ll>>
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::ostream& operator<<(std::ostream& os, pair<T, T>& p) {
  return os << "{ " << p.first << ", " << p.second << " }" << std::endl;
}
template <typename T>
std::istream& operator>>(std::istream& is, pair<T, T>& p) {
  return is >> p.first >> p.second;
}
template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& a) {
  for (T& x : a) is >> x;
  return is;
}

[[maybe_unused]] constexpr ll MOD = 1e9 + 7;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n + 1);
  cin >> a;
  int k = 100000;
  rep(i, 0, n) { k = min(k, abs(a[i] - a[i + 1])); }

  cout << k << '\n';
  rep(i, 0, k) {
    rep(j, 0, n + 1) { cout << (a[j] + i) / k << ' '; }
    cout << '\n';
  }

  return 0;
}
// clang-format off
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;
using namespace __gnu_pbds;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
// clang-format on

string s[100];

int main() {
    fastio();

    int h, w;

    cin >> h >> w;
    forn(i, h) cin >> s[i];

    int ans = 0;
    forn(i, h) forn(j, w) {
        if (s[i][j] == '#') continue;

        if (j < w - 1) {
            ans += s[i][j + 1] == '.';
        }

        if (i < h - 1) {
            ans += s[i + 1][j] == '.';
        }
    }

    cout << ans << endl;

    return 0;
}