#include <stdio.h>
#include <stdlib.h>

int func(int **a, int x, int y, int n, int m)
{
	int c = 1;
	if(a[y][x] == 1){
		return 0;
	}
	a[y][x] = 1;
	
	if(x-1 >= 0){
		c += func(a, x-1, y, n, m);
	}
	if(y-1 >= 0){
		c += func(a, x, y-1, n, m);
	}
	if(x+1 < n){
		c += func(a, x+1, y, n, m);
	}
	if(y+1 < m){
		c += func(a, x, y+1, n, m);
	}
	
	return c;
}

int main(int argc, char **argv)
{
	int **a, n, m, x, y, i, j;
	char *w;
	
	while(1){
		scanf("%d %d", &n, &m);
		if(n == 0){
			break;
		}
		
		a = (int **)calloc(m, sizeof(int));
		for(i = 0; i < m; i++){
			a[i] = (int *)calloc(n, sizeof(int));
			w = (char *)malloc((n+1)*sizeof(char));
			scanf("%s", w);
			for(j = 0; j < n; j++){
				if(w[j] == '@'){
					x = j;
					y = i;
				} else if(w[j] == '#'){
					a[i][j] = 1;
				}
			}
			free(w);
		}
		
		printf("%d\n", func(a, x, y, n, m));
		for(i = 0; i < m; i++){
			free(a[i]);
		}
		free(a);
	}
	
	return 0;
}