#include<bits/stdc++.h>
using namespace std;
const int mxn=3e3+3;
int n,m;
int par[mxn];
inline int find(int x){return par[x]==x?x:par[x]=find(par[x]);}
inline void uni(int x,int y){par[find(x)]=find(y);}
set<int>s1,s2;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n+m;++i)par[i]=i;
	uni(1,n),uni(1,n+1),uni(1,n+m);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
		char c;cin>>c;
		if(c=='#')uni(i,n+j);
	}
	for(int i=1;i<=n;++i)s1.insert(find(i));
	for(int i=1;i<=m;++i)s2.insert(find(i+n));
	cout<<min(s1.size(),s2.size())-1<<'\n';
	return 0;
}
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
const int maxn = 2e5+5;
#define mod 1000000009 


void solve(){
  
  int n,m;
  cin >> n>> m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
  	cin >> a[i];
  }
  
  if( m==0){
  	cout << 1 << endl;
  	return;
  }


  sort(a.begin(),a.end());
  vector<int> widths;
  for(int i=0;i<m-1;i++){
  	if(a[i+1]-a[i]-1 > 0)
  	widths.push_back(a[i+1]-a[i]-1);
  }

  if(a[0] > 1)
   widths.push_back(a[0]-1);
  if( n-a[m-1] > 0)
  widths.push_back(n-a[m-1]);

  // for(auto i: widths) cout << i <<" ";
  // 	cout << endl;
  if( widths.empty() || m == 0) {
  	cout << 0 <<endl;
  	return;
  }
  int mn = *min_element(widths.begin(),widths.end());
  int ans =0;

  for(auto i : widths){
  	ans += (i+mn-1)/mn;
  }


  if(widths.empty()) cout << 0 << endl;
  else cout << ans << endl;
}

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int tc = 1;
  // cin >> tc;
   while(tc--) solve();
  
 return 0;
}