@dx = [-1, 0, 1, 0]
@dy = [0, 1, 0, -1]
@field = []

def is_inside(x, y)
  return x >= 0 && y >= 0 && x < @field[0].length && y < @field.length
end

def count(x, y)
  ret = 1
  @field[y][x] = '#'
  (0 ... @dx.length).each do |i|
    if is_inside(x+@dx[i], y+@dy[i]) and @field[y+@dy[i]][x+@dx[i]] == '.' then
      ret += count(x+@dx[i], y+@dy[i])
    end
  end
  return ret
end

until (n, m = gets.split.map(&:to_i)) == [0, 0]
  @field = []
  m.times {@field << gets.chomp}
  x = 0
  y = 0
  (0 ... m).each do |i|
    x = @field[i].index('@')
    if x != nil then
      y = i
      break
    end
  end
  puts count(x, y)
end