#include<bits/stdc++.h>
using namespace std;
int n,m,sum=0;
char ch[501][501];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>ch[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(ch[i][j]=='*') continue;
else{
if(ch[i-1][j]!='*'||ch[i+1][j]!='*'||ch[i][j-1]!='*'||ch[i][j+1]!='*'){
ch[i][j]='w';
}
}
}
}
// for(int i=1;i<=n;i++){
// cout<<endl;
// for(int j=1;j<=m;j++){
// cout<<ch[i][j]<<" ";
// }
// }
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(ch[i][j]=='0') {
sum++;
}
}
}
cout<<sum;
return 0;
}
/**************************************************************
Problem: 1913
User: caizhihao
Language: C++
Result: Wrong Answer
****************************************************************/