#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<set>
#include<map>
#include<queue>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define pbk push_back
#define mk make_pair
using namespace std;
const int N = 100+10;
typedef long long LL;
typedef pair<int,int> pii;
int w,h,n;
int mz[N][N];
int sx,sy,ex,ey;
int vis[N][N];
struct node{
    int x,y,c;
    node(int x=0,int y=0,int c=0):x(x),y(y),c(c){}
    bool operator < (const node &p)const{
        return c > p.c;
    }
};
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
priority_queue<node> q;
int InMz(int x,int y) {
    if (x <= 0 || x >= 2*w || y <= 0 || y >= 2*h) return 0;
    return 1;
}
int bfs(int sx,int sy,int ex,int ey) {
    while (!q.empty()) q.pop();
    for (int i = 0; i <= w*2; i++) {
        for (int j = 0; j <= h*2; j++) vis[i][j] = N*N;
    }
   // cout<<sx<<" "<<sy<<" "<<ex<<" "<<ey<<endl;
    vis[sx][sy] = 0;
    q.push(node(sx,sy,0));
    while (!q.empty()) {
        node u = q.top(); q.pop();
    //    cout<<u.x<<" "<<u.y<<" "<<u.c<<endl;
        if (u.x == ex && u.y == ey) {
            return u.c;
        }
        for (int i = 0; i < 4; i++) {
            int nx,ny,nnx,nny;
            nx = u.x + dx[i];  ny = u.y + dy[i];
            if (InMz(nx,ny) == 0 || mz[nx][ny] == 1) continue;
            nnx = nx + dx[i];  nny = ny + dy[i];
            if (InMz(nnx,nny) == 0 || mz[nnx][nny] == 1) continue;
            if (vis[nnx][nny] > u.c + 1){
                vis[nnx][nny] = u.c + 1;
                q.push(node(nnx,nny,u.c+1));
            }
        }
    }
    return -1;
}
void solve(){
    scanf("%d%d%d%d",&sx,&sy,&ex,&ey);

    sx = sx*2+1; sy = sy*2+1;
    ex = ex*2+1; ey = ey*2+1;
    int b = bfs(sx,sy,ex,ey);
//    cout<< b <<" ++++ "<<endl;
    int ret = 0;
    //mz[2][3] = 1;
    //cout<< bfs(sx,sy,ex,ey)<<endl;
    for (int i = 1; i < 2*w; i++) {
        for (int  j = 1; j < 2*h; j++) {
            if ((i+j)%2 && mz[i][j] == 0){
                mz[i][j] = 1;
                int tmp = bfs(sx,sy,ex,ey);

           //     cout<<tmp <<" "<< i << " "<<j<<endl;
                if (tmp - b >  ret && tmp != -1) {
                    ret = tmp - b;
                }
                mz[i][j] = 0;
            }
        }
    }
    printf("%d\n",ret);
}
void debug(){
    for (int i = 0; i <= 2*w; i++) {
        for (int  j = 0; j <= 2*h; j++) cout<<mz[i][j]<<" ";
        cout<<endl;
    }
}
int main(){
    while (~scanf("%d%d%d",&w,&h,&n)) {
        memset(mz,0,sizeof(mz));
        for (int  i =0 ; i <= 2*w; i++) {
            mz[i][0] = mz[i][2*h] = 1;
        }
        for (int i = 0; i <= 2*h; i++) {
            mz[0][i] = mz[2*w][i] = 1;
        }
        for (int i = 0 ; i < n; i++) {
            int sx,sy,ex,ey;
            scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
            if (sx == ex) {
                if (sy > ey) swap(sy,ey);
                for (int j = sy*2; j <= ey*2; j++) mz[sx*2][j] = 1;
            }else if (sy == ey) {
                if (sx > ex) swap(sx,ex);
                for (int  j = sx*2; j <= ex*2; j++) mz[j][sy*2] = 1;
            }
          //  debug();
           // cout<<" **** "<<endl;
        }
       // debug();
        solve();


    }


    return 0;
}

Measured memory_bytes: 1292