def search(a, x, y, w, h, count)
  if x+1 < w and a[y][x+1] != nil and a[y][x+1] == '.' and not count.include? [x+1,y]
    count << [x+1,y]
    search(a, x+1, y, w, h, count)
  end
  if x-1 >= 0 and a[y][x-1] != nil and a[y][x-1] == '.' and not count.include? [x-1,y]
    count << [x-1,y]
    search(a, x-1, y, w, h, count)
  end
  if y+1 < h and a[y+1][x] != nil and a[y+1][x] == '.' and not count.include? [x,y+1]
    count << [x,y+1]
    search(a, x, y+1, w, h, count)
  end
  if y-1 >= 0 and a[y-1][x] != nil and a[y-1][x] == '.' and not count.include? [x,y-1]
    count << [x,y-1]
    search(a, x, y-1, w, h, count)
  end
end

loop do
  w, h = gets.split.map(&:to_i)
  exit if w == 0 and h == 0
  a = h.times.map.with_index{gets.chomp.chars}

  x = y = 0
  y = a.find_index{|a| a.index("@")}
  x = a[y].index("@")

  count = []
  search(a, x, y, w, h, count)
  puts (count.length + 1)
end