#include <cstring>
#include <functional>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

const int vx[4] = {0, 1, 0, -1}, vy[4] = {1, 0, -1, 0};

int solve(int H, int W, std::string s[]) {
	int ret = 0;
  int sx, sy;
	bool is_searched[21][21];

	std::memset(is_searched, false, sizeof is_searched);

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (s[i][j] == '@') {
        sx = i, sy = j;
        break;
      }
    }
  }

  std::function<int(int, int)> dfs = [&](int x, int y) {
    int res = 0;
    is_searched[x][y] = true;

    for (int i = 0; i < 4; ++i) {
      int nx = x + vx[i], ny = y + vy[i];

      if (0 <= nx && nx < H && 0 <= ny && ny < W &&
          !is_searched[nx][ny] && s[nx][ny] == '.') {

        res += dfs(nx, ny) + 1;
      }
    }

    return res;
  };

  ret = dfs(sx, sy) + 1; // +1 は'@' の分

	return ret;
}

int main() {
	int W, H;
	std::string s[21];

	while(cin >> W >> H, W | H) {
		for(int i = 0; i < H; ++i) {
			cin >> s[i];
		}

		int ans = solve(H, W, s);

		cout << ans << endl;
	}

	return 0;
}

