def solve(x, y, dir, s, w, h)
  @vis[y][x] = 1
  (x>0 && dir!=1 && s[y][x-1]=="." && @vis[y][x-1]==0) ? (lf = 1+solve(x-1,y,2,s,w,h)):(lf = 0)
  (x<w-1 && dir!=2 && s[y][x+1]=="." && @vis[y][x+1]==0) ? (ri = 1+solve(x+1,y,1,s,w,h)):(ri = 0)
  (y>0 && dir!=3 && s[y-1][x]=="." && @vis[y-1][x]==0) ? (up = 1+solve(x,y-1,4,s,w,h)):(up = 0)
  (y<h-1 && dir!=4 && s[y+1][x]=="." && @vis[y+1][x]==0) ? (dw = 1+solve(x,y+1,3,s,w,h)):(dw = 0)
  return lf+ri+up+dw
end
  

while (ln = gets.chomp) != "0 0"
  w,h = ln.split.map(&:to_i)
  s = h.times.map{gets.chomp.split("")}
  
  @vis = Array.new(h).map{Array.new(w,0)}
  for i in 0..(h-1)
    for j in 0..(w-1)
      if s[i][j] == "@"
        sx = j
        sy = i
        break
      end
    end
  end
  
  puts solve(sx, sy, 0, s, w, h)+1
end
