import java.util.Scanner

var map: Array<CharArray>? = null
val sides = arrayOf(Pair(-1,0), Pair(0,-1), Pair(0,1), Pair(1,0))
fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	while(true){
		val w = scanner.nextInt()
		val h = scanner.nextInt()
		if (w==0 && h==0) break
		var xbeg: Int = -1
		var ybeg: Int = -1
		map = Array(h){
			val cs = scanner.next().toCharArray()
			val x = cs.indexOf('@')
			if (x!=-1) {
				xbeg=x
				ybeg=it
			}
			return@Array cs
		}
		println(rec(xbeg, ybeg, w, h))
	}

}

fun rec(x: Int, y: Int, w: Int, h: Int): Int{
	var ans = 1
	for (side in sides){
		val nx = x+side.first
		val ny = y+side.second
		if (nx !in 0 until w) continue
		if (ny !in 0 until h) continue
		if  (map!![ny][nx]=='.') {
			map!![ny][nx]='@'
			ans += rec(nx, ny, w, h)
		}
	}
	return ans
}
