int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1};
memset(st, false, sizeof st); while(!q.empty()) { auto t = q.front(); q.pop();
if (st[t.x][t.y]) continue; st[t.x][t.y] = true; cnt ++;
for (int i = 0; i < 4; ++i) { int x = t.x + dx[i], y = t.y + dy[i]; if (x < 0 || x >= n || y < 0 || y >= m || g[x][y] == '#') continue; q.push({x, y}); } }
return cnt; }
intmain() { cin >> m >> n; while(n != 0 && m != 0) { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> g[i][j]; if (g[i][j] == '@') { start.x = i; start.y = j; g[i][j] = '.'; } } }