public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		while ((line = in.readLine()) != null && line.length() != 0) {
			int[] nm = readInts(line);
			n = nm[0];
			m = nm[1];
			if (n == 0 && m == 0)
				break;
			map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = in.readLine().trim().toCharArray();
			int deposits = 0;
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					if (map[i][j] == '@') {
						deposits++;
						map[i][j] = '*';
						floodFill(i, j);
					}
			out.append(deposits + "\n");
		}
		System.out.print(out);
	}