//author:luckYrat(twitter:@luckYrat_) #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; const int mod = 1000000007; const int inf = (1<<30)-1; const ll linf = (1LL<<62LL)-1; const double EPS = (1e-10); #define anyfill(n,s) setw(n) << setfill(s) #define loop(s) for(int i = 0; s > i; i++) #define rep(i,q) for(int i = 0; (q) > i; i++) #define repp(i,n,q) for(int i = n; (q) > i; i++) #define dep(i,q) for(int i = (q); 0 < i; i--) #define pb push_back #define fir first #define scn second #define ednl endl #define YesNo(a) (a?"Yes":"No") #define YESNO(a) (a?"YES":"NO") #define yesno(a) (a?"yes":"no") P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}}; P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; char mp[1000][1000]; struct z{ int x,y,p; }; __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } int main(){ int x,y;cin>>x>>y; int sy,sx,gy,gx;cin>>sy>>sx>>gy>>gx; for(int i = 0; x > i; i++){ for(int j = 0; y > j; j++){ cin>>mp[i][j]; } } cout << abs(gy-sy)+abs(gx-sx) << endl; }