//新生训练
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
using PII = pair<int, int>;
const int N = 205;
int n, m;
int dis[N][N];
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dy[] = {-1, 1, 0, 0, -1, 1, 1, -1};
char a[N][N];
void bfs(int fx, int fy)
{
dis[fx][fy] = 0;
queue<PII> q;
q.push(make_pair(fx, fy));
while (!q.empty())
{
PII t = q.front();
q.pop();
int x = t.first, y = t.second;
for (int i = 0; i < 8; ++i)
{
int ix = x + dx[i], iy = dy[i] + y;
if (ix && iy && ix <= n && iy <= m && dis[ix][iy] == -1 && a[ix][iy] != '*')
{
dis[ix][iy] = dis[x][y];
q.push(make_pair(ix, iy));
}
}
}
}
void dacapo()
{
while (cin >> n >> m && n && m)
{
memset(dis, -1, sizeof dis);
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
cin >> a[i][j];
}
}
int ans = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (a[i][j] == '@' && dis[i][j] == -1)
{
++ans;
bfs(i, j);
}
}
}
cout << ans << '\n';
}
}
signed main()
{
int ciao = 1;
while (ciao--)
{
dacapo();
}
return 0;
}
//其实直到学长讲题的时候笔者还没做出来 hwh ;
//此题 BFS 些许复杂,但是学长一讲就明白很多(感谢万能的学长 hwh);
~~~//仅当笔者个人备忘录使用。