import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  loop
  def loop: Unit = {
    val Array(w, h) = readLine.trim.split(' ').map(_.toInt)
    if (w == 0) return
    val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray}
    val start = (0 until h).flatMap(y ⇒ (0 until w).find(x ⇒ state(y)(x) == '@').map(x ⇒ Point(x, y))).head
    val queue = mutable.Queue[Point](start)
    var count = 1
    while(queue.nonEmpty){
      val p = queue.dequeue()
      for (n ← p.neighbor if (0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) == '.') {
        state(n.y)(n.x) = '#'
        queue.enqueue(n)
        count += 1
      }
    }
    println(count)
    loop
  }
  case class Point(x: Int, y: Int) {
    def neighbor = Array(Point(x + 1, y), Point(x - 1, y), Point(x, y + 1), Point(x, y - 1))
  }
}
