#include <bits/extc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,a,b) for(int i=a;i<=int(b);i++)
#define ALL(x) x.begin(),x.end()
#define MOD (ll)1000000007
set<ll> ans;
vector<pair<ll, ll>> xy;

signed main() {
  ll n;
  int m;
  cin >> n >> m;
  ans.insert(n);
  xy.resize(m);
  REP(i, m){
    ll x, y;
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }
  ll xb = 0;
  if(m > 0) { 
    sort(xy.begin(), xy.end());
    xb = xy[0].first;
  }
  vector<ll> dellist(0);
  vector<ll> addlist(0);
  REP(i, m){
    ll x, y;
    tie(x, y) = xy[i];
    if(xb != x){
      for(ll del: dellist){
        if(ans.find(del) != ans.end()) ans.erase(del);
      }
      for(ll add: addlist){
        if(ans.find(add) == ans.end()) ans.insert(add);
      }
      dellist.clear();
      addlist.clear();
    }
    if(ans.find(y) != ans.end()){
      dellist.push_back(y);
      
    }
    if(y - 1 >= 0){
      if(ans.find(y - 1) != ans.end()){
        addlist.push_back(y);
      }
    }
    if(y + 1 <= 2 * n){
      if(ans.find(y + 1) != ans.end()){
        addlist.push_back(y);
      }
    }
    xb = x;
  }
  for(ll del: dellist){
    if(ans.find(del) != ans.end()) ans.erase(del);
  }
  for(ll add: addlist){
    if(ans.find(add) == ans.end()) ans.insert(add);
  }
  cout << ans.size();
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n,m,sum=0;
char str[15][15];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>str[i]+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(str[i][j]!='#')continue;
			int u=0;
			if(str[i][j-1]=='#'||(str[i][j-1]!='#'&&str[i-1][j-1]!='#'&&str[i-1][j]=='#'))u+=1;
			if(str[i][j+1]=='#'||(str[i][j+1]!='#'&&str[i+1][j+1]!='#'&&str[i+1][j]=='#'))u+=2;
			if(str[i-1][j]=='#'||(str[i-1][j]!='#'&&str[i-1][j-1]!='#'&&str[i][j-1]=='#'))u+=4;
			if(str[i+1][j]=='#'||(str[i+1][j]!='#'&&str[i+1][j+1]!='#'&&str[i][j+1]=='#'))u+=8;
			sum+=4-__builtin_popcount(u);
			//cout<<i<<' '<<j<<' '<<u<<' '<<sum<<endl;
		}
	}
	cout<<sum;
    return 0;
}