#include <iostream>

using namespace std;

const int kMaxN = 20;
const int kMaxL = 73;
const int kP[kMaxN] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};

int s[kMaxL], c;
long long f[kMaxL + 1][1 << kMaxN], a, b, ans;

long long C(int i, int j) {
  if (f[i][j]) {
    return f[i][j];
  }
  f[i][j] = 1;
  for (int k = i; k <= b - a; k++) {
    if (s[k] && (j & s[k]) == 0) {
      f[i][j] += C(k + 1, j | s[k]);
    }
  }
  return f[i][j];
}

int main() {
  cin >> a >> b;
  for (long long i = a; i <= b; i++) {
    for (int j = 0; j < kMaxN; j++) {
      s[i - a] |= (i % kP[j] == 0) << j;
    }
    c += !s[i - a];
  }
  cout << C(0, 0) * (1 << c);
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int N = 15;

char s[N][N], aux[N][N];

void rot(int &m, int &n) {
	for(int i = 0; i < m; ++i)
		for(int j = 0; j < n; ++j)
			aux[n - 1 - j][i] = s[i][j];

	swap(m, n);
	for(int i = 0; i < m; ++i)
		for(int j = 0; j < n; ++j)
			s[i][j] = aux[i][j];
}

int solve(int m, int n) {
	int last, res = 0;

	for(int j = 1; j < n; ++j) {
		last = -2;
		for(int i = 0; i < m; ++i)
			if(s[i][j] == '#' && s[i][j - 1] == '.') {
				if(i != last + 1) ++res;
				last = i;
			}
	}

	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int m, n;

	cin >> m >> n;

	for(int i = 0; i < m; ++i) cin >> s[i];

	int ans = 0;
	for(int i = 0; i < 4; ++i) {
		rot(m, n);
		/*for(int r = 0; r < m; ++r, cerr << '\n')
			for(int c = 0; c < n; ++c) cerr << s[r][c];
		cerr << '\n';*/
		ans += solve(m, n);
	}

	cout << ans << '\n';

	return 0;
}
