# field[x][y], field[h][w]

def debug_field(field)  
  puts field.map {|x| x.join("")}.join("\n")
end

def bfs(h, w, i, j, field)
  items = []
  items << [i, j]
  field[i][j] = '#'
  count = 1
  until items.empty?
    v = items.shift
    [[1, 0], [0, 1],
     [-1, 0], [0, -1]].each do |dx, dy|
      x_new, y_new = [v[0] + dx, v[1] + dy]
      next if x_new >= h or x_new < 0
      next if y_new >= w or y_new < 0
      next if field[x_new][y_new] == '#'
      count += 1
      field[x_new][y_new] = '#'
      items << [x_new, y_new]
    end
  end
  count
end

def solve(height, width, field)
  field.each.with_index do |row, i|
    row.each.with_index do |t, j|
      return puts bfs(height, width, i, j, field) if t == '@'
    end
  end
end

data = $stdin.read.split("\n")
until data.empty?
  width, height = data[0].split(" ").map(&:to_i)
  field = data[1..-1].map(&:chars)
  solve height, width, field
  data = data[(height + 1)..-1]
end