#include<iostream>
//#include<bits/stdc++.h>
#define r read()
#define bb printf("!!\n");
#define cc printf("\n");
using namespace std;
inline int read()
{
	bool ok=0 ;int res=0;char c;
	while(((c=getchar())<'0'||c>'9')&&c!='-');
	if(c=='-') ok=1;else res=c-48;
	while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+(c-48);
	return ok ? ~res + 1:res;
}
int n,m;
int main()
{
 #ifndef ONLINE_JUDGE
//	freopen("cin.txt","r",stdin);
//	freopen("cout.txt","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	a+=b;
	int ans=4;
	if(a>=15&&b>=8)ans=1;
	else if(a>=10&&b>=3)ans=2;	
	else if(a>=3)ans=3;
	printf("%d\n",ans);

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int h,w,ans=0;
    cin >> h >> w;
    vector<string>s(h);
    rep(i,h)cin >> s[i];
    
    rep(i,h){
        rep(j,w){
            if(j!=w-1 and s[i][j]=='.' and s[i][j+1]=='.')ans++;
            if(i!=h-1 and s[i][j]=='.' and s[i+1][j]=='.')ans++;
        }
    }
    
    cout << ans;
    
    return 0;
}