#include <bits/stdc++.h>
using namespace std;
const int N = 200;
char mp[N][N];
map<string, int> mpp;
inline void findwh(int &w, int &h, int r, int c){
bool flag1 = false, flag2 = false;
int lhcx, lhcy, rdcx, rdcy;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++){
if(flag1 && flag2){
w = rdcx - lhcx + 1, h = rdcy - lhcy + 1;
return;
}
if(mp[i - 1][j - 1] == '#' && mp[i - 1][j] == '#' && mp[i][j - 1] == '#' && !flag1){ flag1 = true, lhcx = i - 1, lhcy = j - 1; }
if(mp[i + 1][j + 1] == '#' && mp[i + 1][j] == '#' && mp[i][j + 1] == '#' && !flag2){ flag2 = true, rdcx = i + 1, rdcy = j + 1; }
}
}
signed main(){
int r, c; cin >> r >> c;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++) cin >> mp[i][j];
int w = 1, h = 1; //!w--横向宽度
findwh(h, w, r, c);
if(w == c && h == r) return cout << 1 << endl, 0;
for(int i = 1; i <= r - 1; i += (h - 1)){
for(int j = 1; j <= c - 1; j += (w - 1)){
string now1, now2, now3, now4;
for(int m = i; m <= i + h - 1; m++) for(int n = j; n <= j + w - 1; n++) now1 += mp[m][n];
for(int m = j + w - 1; m >= j; m--) for(int n = i; n <= i + h - 1; n++) now2 += mp[n][m];
for(int m = i + h - 1; m >= i; m--) for(int n = j + w - 1; n >= j; n--) now3 += mp[m][n];
for(int m = j; m <= j + w - 1; m++) for(int n = i + h - 1; n >= i; n--) now4 += mp[n][m];
if(mpp.count(now1) || mpp.count(now2) || mpp.count(now3) || mpp.count(now4)) continue;
else mpp[now1] = 1;
}
}
cout << mpp.size() << endl;
return 0;
}