W,H,C;char m[484];R(i){m[i]>45?m[i]=0,C++,R(i-1),R(i+1),R(i-W),R(i+W):0;}main(i){for(;scanf("%d%d",&W,&H)*W;i=m,R(strchr(m,64)-i),C=!printf("%d\n",C))for(memset(m,W++,484),i=H*W;i--;)m[W+i]=getchar();}