object Main {
  val dir = List((-1, 0), (0, 1), (1, 0), (0, -1))

  def inCheck(w: Int, h: Int, y: Int, x: Int) = {
    0 <= y && y < h && 0 <= x && x < w
  }

  def solve(w: Int, h: Int, tiles: List[String]): Int = {
    var sx, sy = 0
    tiles.zipWithIndex.foreach(t => 
      for(x <- 0 until w) {
        if(t._1(x) == '@') {
          sx = x; sy = t._2
        }
      })
    val used = Array.fill[Boolean](h, w)(false)
    val queue = new scala.collection.mutable.Queue[List[Int]]
    queue += List(sy, sx)
    var count = 1
    while(queue.size != 0) {
      val pos = queue.dequeue
      for(d <- dir) {
        val my = pos(0) + d._1
        val mx = pos(1) + d._2
        if(inCheck(w, h, my, mx) && tiles(my)(mx) == '.' && !used(my)(mx)) {
          used(my)(mx) = true
          count += 1
          queue += List(my, mx)
        }
      }
    }
    count
  }

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var w, h = sc.nextInt
    while(h != 0 || w != 0) {
      val tiles = for(_ <- 1 to h) yield sc.next
      println(solve(w, h, tiles.toList))
      w = sc.nextInt; h = sc.nextInt
    }
  }
}