#include using namespace std; using ll = long long; int main() { ll top = 201,bottom = -1,left = 201,right = -1,h,w,a,b,p,q; cin >> h >> w >> a >> b; vector> bug(2); for(int i = 0;i < 2;i++){ int tmp1,tmp2; cin >> tmp1 >> tmp2; bug.at(i) = make_pair(tmp1,tmp2); } cin >> p >> q; ll ans = 10000000000; for(int i = bug.at(0).first;i <= bug.at(1).first;i++){ for(int j = bug.at(0).second;j <= bug.at(1).second;j++){ ll s = abs(a - p) + abs(b - q); s += abs(p - i) + abs(q - j); s += abs(a - i) + abs(b - j); ans = min(ans,s); } } cout << ans << endl; }