#include<bits/stdc++.h>
#define DilligentArch() ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define testcase(t) int t; cin>>t; while(t--)
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 1e5+10;
vector<int>g[N];
bool cat[N];
ll ct=0;
ll n,m;
char arr[N][N];
void dfs(ll i, ll j) {
if(i<0 or j<0) return;
if(i>=n or j>=m) return;
if(arr[i][j]!= '.' or arr[i][j]!='@')return;
ct++;
dfs(i-1,j);
dfs(i+1,j);
dfs(i,j-1);
dfs(i,j+1);
}
void solve()
{
cin>>n>>m;
ll x,y;
for(ll i=0; i<n; i++) {
for(ll j=0; j<m; j++) {
cin>>arr[i][j];
if(arr[i][j]=='@') {
x=i;
y=j;
}
}
}
arr[x][y]='.';
dfs(x,y);
cout<<ct<<endl;
}
int main()
{
DilligentArch()
// testcase(t){
solve();
} //}