def move(x,y,a)
  return if(x < 0)
  return if(y < 0)
  return if(a.size <= y)
  return if(a[0].size <= x)
  return if(a[y][x] == "#")
  a[y][x] = "#"
  @ans += 1
  move(x + 1, y ,a)
  move(x - 1, y, a)
  move(x, y + 1, a)
  move(x, y - 1, a)
end
while (true)
  w,h = gets.split.map &:to_i
  break if(w == 0)
  d = []
  @ans = 0
  x = y = 0
  h.times do |i|
    d[i] = gets.chomp
    if(d[i].include?("@"))
      y = i
      x = d[i].index("@")
    end
  end
  move(x, y, d)
  p @ans
end