#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> to;

vector<int> used, color, order;

int now;

void dfs(int i){
  if(used[i] == 1) return;
  used[i] = 1;
  order.push_back(i);
  for(int s: to[i]) dfs(s);
}

void color_dfs(int i){
  if(i == order.size()){
    // for(int c: color) cout << c << " ";
    // cout << endl;
    now++;
    return;
  } 
  int o = order[i];
  rep(c,3){
    bool ok = true;
    for(int s: to[o]) if(c == color[s]) ok = false;
    if(ok){
      color[o] = c;
      color_dfs(i+1);
    }
  }
  color[o] = -1;
  return;
}

int main()
{
  int n, m;
  cin >> n >> m;
  to = vector<vector<int>>(n);

  int a, b;
  rep(i,m){
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  long long ans = 1;

  used = vector<int>(n,0);
  color = vector<int>(n,-1);
  rep(i,n){
    if(used[i] == 1) continue;
    // used[i] = 1;
    order = vector<int>();
    dfs(i);

    // cout << "dfs is finished" << endl;
    // cout << "order" << endl;
    // for(int o: order) cout << o << " ";
    // cout << endl;

    now = 0;
    color[i] = 0;
    color_dfs(1);
    ans *= 3*now;
  }
  cout << ans << endl;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int ans = 0;
	rep(i, h) {
		rep(j, w - 1) {
			if (s[i][j] == '.' && s[i][j + 1] == '.') ans++;
		}
	}
	rep(j, w) {
		rep(i, h - 1) {
			if (s[i][j] == '.' && s[i + 1][j] == '.') ans++;
		}
	}
	cout << ans << endl;
	return 0;
}