#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793
//#include <atcoder/all>
//using namespace atcoder;
//using Mint = modint;

struct UnionFind{
	vector<int> par,siz;
	UnionFind(int N): par(N), siz(N){
		rep(i, N){
			par[i] = i; siz[i] = 1;
		}
	}
	int root(int x){
		if(par[x]==x) return x;
		else return root(par[x]);
	}
	void unite(int x, int y){
		x=root(x); y=root(y);
		if(x==y) return;
		if(siz[x] < siz[y]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int size(int x){
		return siz[root(x)];
	}
};

int main(){
  int h, w; cin >> h >> w; string s[h]; UnionFind uf(2020);
  rep(i, h){
    cin >> s[i];
  }
  uf.unite(0, w-1);
  uf.unite(w, h+w-1);
  rep(i, h){
    set<int> yoko;
    rep(j, w){
      if((i==0 || i==h-1) && s[i][j]=='#'){
        uf.unite(0, j);   //cout << 0 << " " << j << endl;
      }
      if(s[i][j]=='#') yoko.insert(j);
    }
    auto itr = yoko.begin();
    for(auto k: yoko){
      uf.unite(*itr, k);
      //cout << *itr << " " << k << endl;
    }
    yoko.clear();
  }
  rep(j, w){
    set<int> tate;
    rep(i, h){
      if((j==0 || j==w-1) && s[i][j]=='#'){
        uf.unite(w, w+i);   //cout << w << " " << w+i << endl;
      }
      if(s[i][j]=='#') tate.insert(w+i);
    }
    auto itr = tate.begin();
    for(auto k: tate){
      uf.unite(*itr, k);
      //cout << *itr << " " << k << endl;
    }
    tate.clear();
  }
  set<int> ansa, ansb;
  rep(i, w){
    ansa.insert(uf.root(i));
  }
  for(int i=w; i<=h+w-1; i++){
    ansb.insert(uf.root(i));
  }
  cout << min(ansa.size()-1, ansb.size()-1) << endl;
}
  
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}

void Main(){
    int N; double D,H; cin >> N >> D >> H;
    VI d(N),h(N); REP(i,N) cin >> d[i] >> h[i];

    double ng = 0, ok = 1000;
    REP(_,50){
        double b = (ok+ng)/2;
        double a = (H-b)/D;
        bool flag = true;
        REP(i,N){
            if(a*d[i]+b < h[i]){
                flag = false;
                break;
            }
        }
        if(flag) ok = b;
        else ng = b;
    }
    cout << ok << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    while(t--) Main();
    return 0;
}