w,h,c,j,g;char*p,f[999],*q;main(i){for(;scanf("%d%d",&w,&h),w++;printf("%d\n",c)){memset(f,35,900);for(i=1;i<=h;i++)scanf("%s",f+i*w+i+1),f[strchr(f,0)-f]=35;for(c=g=1;g;)for(p=f,g=0;p=strchr(p+1,64);)for(j=0;j<2;j++)*(q=(p+j*w+1))-46||(*q=64,g|=c++),*(q=(p-j*w-1))-46||(*q=64,g|=c++);}exit(0);}