#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
 
int main() {
  int H,W;cin>>H>>W;
  vector<vector<bool> > Map(H+10,vector<bool>(W+10,false));//黒ならTRUE
  int sy=-1,sx=-1;
  for(int h=1;h<=H;h++){
    string s;cin>>s;
    for(int w=1;w<=W;w++){
      Map[h][w]=(s[w-1]=='#');
      if(Map[h][w]&&sy==-1){
        sy=h;sx=w;
      }
    }
  }
  if(sy==-1){
    cout<<0<<endl;
    return 0;
  }
  int ny=sy,nx=sx;
  int p=0;
  int r=2;//下から来た
  int i=0;
  while(true){
    //i++;
    r=-r;
    bool a1=Map[ny][nx];
    bool a2=Map[ny-1][nx];
    bool a3=Map[ny][nx-1];
    bool a4=Map[ny-1][nx-1];
    int k1,k2;
    if((a1?1:0)+(a2?1:0)+(a3?1:0)+(a4?1:0)==3){
      a1=!a1;a2=!a2;a3=!a3;a4=!a4;
    }
    if(a1&&!a2&&!a3&&!a4){k1=-2;k2=1;}
    if(!a1&&a2&&!a3&&!a4){k1=1;k2=2;}
    if(!a1&&!a2&&a3&&!a4){k1=-2;k2=-1;}
    if(!a1&&!a2&&!a3&&a4){k1=-1;k2=2;}
    if(a1&&a2&&!a3&&!a4){k1=-2;k2=2;}
    if(!a1&&!a2&&a3&&a4){k1=-2;k2=2;}
    if(!a1&&a2&&!a3&&a4){k1=-1;k2=1;}
    if(a1&&!a2&&a3&&!a4){k1=-1;k2=1;}
    int n=99;
    //cout<<a1<<a2<<a3<<a4<<endl;
    //cout<<k1<<" "<<k2<<endl;
    if(r==k1)n=k2;
    else if(r==k2)n=k1;
    if(-n!=r)p++;
    if(n==1)nx++;
    if(n==-1)nx--;
    if(n==2)ny--;
    if(n==-2)ny++;
    //cout<<p<<" "<<ny<<" "<<nx<<endl;

    r=n;
    if(ny==sy&&nx==sx)break;
    if(i>13)break;
  }
  cout<<p<<endl;
}

#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back
#define fi first
#define se second
#define ll long long
#define tp top()
#define fr front()
#define vi vector<int>
#define sz size()
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define mem(a,  b) memset(a,  (b),  sizeof(a))
#define clr(a) memset(a,  0,  sizeof(a))
#define sqr(x) ( (x) * (x) )
#define all(v) v.begin(),  v.end()

typedef pair<int, int> pii;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;



void base(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

vector<pair<double, double>> ps;

#define N 120
int par[N];
int fpar(int n){
	return par[n] = (par[n] == n)? n : fpar(par[n]);
}

double dist(pair<double, double> p1, pair<double, double> p2){
	return hypot(p1.fi-p2.fi, p1.se-p2.se);
}

void solve(){
	int n; cin>>n;
	rep(i,0,n){
		double x,y;cin>>x>>y;
		ps.pb({x,y});
		par[i]=i;		
	}
	par[n]=n;
	par[n+1]=n+1;
	
	priority_queue<pair<double, pii>, vector<pair<double, pii>>, greater<pair<double, pii> > > pq;
	
	rep(i,0,n){
		pq.push({100-ps[i].se,{i,n}});
		pq.push({ps[i].se-(-100),{i,n+1}});
		rep(j,i+1,n){
			pq.push({dist(ps[i],ps[j]),{i,j}});
		}
	}
	
	double ans = 0;
	
	while(pq.sz){
		double range = pq.tp.fi;
		int x = pq.tp.se.fi;
		int y = pq.tp.se.se;
		pq.pop();
		
		int p1 = fpar(x);
		int p2 = fpar(y);
		if (p1 != p2) {
			par[p1] = p2;			
			int pn = fpar(n);
			int pm = fpar(n+1);
			ans = range;
			if (pn == pm) break;
		}		
	}
	
	cout<<fixed<<setprecision(9)<<ans/2.0<<"\n";
}

int main()
{
	base();
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}




