def dfs cx, cy, lines, visited
  return 0 if visited.include? [cx, cy]
  visited << [cx, cy]

  # p [cx, cy]
  # p [lines[cy][cx + 1], lines[cy][cx - 1], lines[cy + 1][cx], lines[cy - 1][cx]]
  res = 1
  res += dfs cx + 1, cy, lines, visited if lines[cy][cx + 1] == "."
  res += dfs cx - 1, cy, lines, visited if lines[cy][cx - 1] == "."
  res += dfs cx, cy + 1, lines, visited if lines[cy + 1][cx] == "."
  res += dfs cx, cy - 1, lines, visited if lines[cy - 1][cx] == "."

  res
end

loop do
  w, h = gets.split.map(&:to_i)
  break if w == 0
  x = 0
  y = 0
  lines = [["#"] * (w + 2)] # ??????
  1.upto(h) do |i|
    line = "##{gets.chomp}#".split "" # ??????
    idx = line.index("@")
    if idx
      line[idx] = "."
      x = idx
      y = i
    end
    lines << line
  end
  lines << ["#"] * (w + 2) # ??????

  # require "pp"
  # pp lines
  # p [[x, y]]
  puts dfs x, y, lines, []
end