def space_input(p=''):
s=raw_input(p).split()
for i in range(len(s)):
s[i]=eval(s[i])
return tuple(s)
class Mymap:
def __init__(self,w,h):
self.x=0
self.y=0
self.height=h
self.width=w
self.safe=0
self.map=[[' ' for i in range(w)] for i in range(h)]
def getmap(self):
for i in range(self.height):
line=raw_input()
for j in range(self.width):
self.map[i][j]=line[j]
if line[j]=='@':
self.x,self.y=i,j
self.map[i][j]='.'
def open(self,x,y):
if self.map[x][y]=='.':
self.map[x][y]='#'
self.safe+=1
for i,j in [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]:
if 0<=i<self.height and 0<=j<self.width:
self.open(i,j)
w,h=space_input()
while w or h:
a=Mymap(w,h)
a.getmap()
a.open(a.x,a.y)
print a.safe
w,h=space_input()
/**************************************************************
Problem: 2126
User: admin
Language: Python
Result: Wrong Answer
****************************************************************/