#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=50+10;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
char s[maxn][maxn];
int vis[maxn][maxn];
int ans=0;
int n,m;
string ss;
int num;
set<int> s1;
set<string> s2;
void dfs(int x,int y)
{
vis[x][y]=1;
num++;
rep(i,0,4)
{
int x1=x+dx[i],y1=y+dy[i];
if(x1<1||x1>n||y1<1||y1>m)
{
ss+='0';
continue;
}
if(s[x1][y1]=='#')
{
if(!vis[x1][y1])
{
dfs(x1,y1);
ss+='1'+i;
}
//else ss+='0'; 这句话加上也是可以的
}
else ss+='0';
}
}
int main()
{
scanf("%d%d",&n,&m);
rep(i,1,n+1) scanf("%s",s[i]+1);
int cnt=0;
rep(i,1,n+1) rep(j,1,m+1)
{
if(s[i][j]=='#'&&!vis[i][j])
{
cnt++;
ss="";
num=0;
dfs(i,j);
s1.insert(num);
s2.insert(ss);
}
}
printf("%d %d %d\n",cnt,(int)s1.size(),(int)s2.size());
return 0;
}