#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 1005;
struct Union_Find_Set{
	int fa[N*N]; bool val[N*N];
	inline void init(){
		for (int i = 1; i <= 1000005; ++i) fa[i] = i,val[i] = 0;
	}
	inline int F(int x){
		return x == fa[x] ? x : (fa[x] = F(fa[x]));
	}
	inline void Merge(int x,int y){
		x = F(x),y = F(y); if (x == y) return;
		fa[x] = y,val[y] |= val[x];
	}
	inline void tag(int x){
		val[F(x)] = 1;
	}
}S;
int n,m;
char mp[N][N]; int id[N][N],cntid;

int solve(){
	int i,j; int ans = 0;
	cntid = 0,S.init();
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) id[i][j] = 0;
	for (i = 1; i <= n; ++i){
		bool flag = 1; int lst = -1;
		for (j = 1; j <= m; ++j) if (mp[i][j] == '#'){
			flag = 0,id[i][j] = ++cntid;
			if (lst != -1) S.Merge(id[i][j],id[i][lst]);
			lst = j; 
			if (i==1||j==1||i==n||j==m) S.tag(id[i][j]);
		}
		if (flag && i > 1 && i < n) ++ans;
	}
	for (j = 1; j <= m; ++j){
		int lst = -1;
		for (i = 1; i <= n; ++i) if (id[i][j]){
			if (lst != -1) S.Merge(id[i][j],lst);
			lst = id[i][j];
		}
	}
	for (i = 1; i <= cntid; ++i) if (i == S.F(i)){
		if (S.val[i]) ; else ++ans;
	}
	return ans;
}

int main(){
	int i,j;
	cin >> n >> m;
	for (i = 1; i <= n; ++i) cin >> mp[i] + 1;
	int ans1 = solve();
	swap(n,m);
	static char mp2[N][N];
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) mp2[i][j] = mp[j][i];
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) mp[i][j] = mp2[i][j];
	cout << min(ans1,solve()) << '\n';
	return 0;
}
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<ll, ll>;
const ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll ans = 1;
	if (b < 0)return 1;
	else if (b % 2 == 0)return(pow(a * a, b / 2));
	else return (a * pow(a, b - 1));
}
ll modpow(ll x, ll n, ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (modpow((x * x) % mod, n / 2, mod) % mod);
	else
		return (x * modpow(x, n - 1, mod)) % mod;
}
template<typename T>
vector<T> primes(T n) {//primes[i]でiを割り切る最初の素数を返す
	vector<T> spf(n + 1);
	for (int i = 0; i <= n; i++) spf[i] = i;
	for (T i = 2; i * i <= n; i++) {
		if (spf[i] == i) {
			for (T j = i * i; j <= n; j += i) {
				if (spf[j] == j) {
					spf[j] = i;
				}
			}
		}
	}
	return spf;
}
void solveA() {
	int v, t, s, d; cin >> v >> t >> s >> d;
	if (v * t <= d && d <= v * s)cout << "No" << endl;
	else cout << "Yes" << endl;
}
void solveB() {
	int n, x; cin >> n >> x;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	rip(i, n) {
		if (a[i] != x)cout << a[i] << endl;
	}
}
void solveC() {
	int h, w; cin >> h >> w;
	vector<string>s(h);
	rip(i, h)cin >> s[i];
	ll sum = 0;
	rip(i, h) {
		rip(j, w) {
			if (s[i][j] == '#') {
				int count = 0;
				if (s[i + 1][j] == '#')count++;
				if (s[i - 1][j] == '#')count++;
				if (s[i][j + 1] == '#')count++;
				if (s[i][j - 1] == '#')count++;
				sum += 4 - count;
			}
		}
	}
	cout << sum << endl;
}
void solveD() {
	ll n; cin >> n;
	//正のみで考えて弐倍すればok
	int count = 0;
	for (int i = 1; (ll)i * i + i <= 2 * n; i++) {
		if ((2 * n) % i == 0 && ((2 * n / i) + 1 - i) % 2 == 0) {
			count += 2;
		}
	}
	cout << count << endl;
}
void solveE() {
	int n, m; cin >> n >> m;
	vector<int>a(m); vector<int>b(m);
	rip(i, m)cin >> a[i] >> b[i];
	int k; cin >> k;
	vector<int>c(k);
	rip(i, k)cin >> c[i];

}
void solveF() {
}
int main() {
	solveA();
}