#include <fstream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main()
{
	ifstream cin("nose.in");
	ofstream cout("nose.out");
	int n, m, ans = 0;
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < 2 * n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		for (int j = 0; j < m - 1; j++)
			if (a[i][j] == '.') ans += a[i][j + 1] == '.', ans += a[i + 1][j] == '.';
	cout << ans << endl;
}

