#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 55

struct Info{
	Info(int arg_node_id,int arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{

		return sum_cost > arg.sum_cost;
	}
	int node_id,sum_cost;
};

int W,H,N;
int num_nodes,start,goal;
int index_table[SIZE][SIZE];
int min_dist[SIZE*SIZE],MIN_DIST[SIZE*SIZE],rev_min_dist[SIZE*SIZE];
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
bool wall[SIZE*SIZE][SIZE*SIZE];
vector<int> G[SIZE*SIZE];


bool rangeCheck(int row,int col){

	return row >= 0 && row <= H-1 && col >= 0 && col <= W-1;
}

void calc_rev(){

	for(int i = 0; i < num_nodes; i++){

		rev_min_dist[i] = BIG_NUM;
	}
	rev_min_dist[goal] = 0;

	priority_queue<Info> Q;
	Q.push(Info(goal,0));

	while(!Q.empty()){

		if(Q.top().sum_cost > rev_min_dist[Q.top().node_id]){

			Q.pop();
		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next = G[Q.top().node_id][i];
				if(wall[Q.top().node_id][next])continue;

				int next_cost = Q.top().sum_cost+1;

				if(rev_min_dist[next] > next_cost){
					rev_min_dist[next] = next_cost;
					Q.push(Info(next,next_cost));
				}
			}
			Q.pop();
		}
	}
}

int func(){

	for(int i = 0; i < num_nodes; i++){

		min_dist[i] = BIG_NUM;
	}
	min_dist[start] = 0;

	priority_queue<Info> Q;
	Q.push(Info(start,0));

	while(!Q.empty()){

		if(Q.top().sum_cost > min_dist[Q.top().node_id]){

			Q.pop();
		}else if(Q.top().node_id == goal){

			return Q.top().sum_cost;
		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next = G[Q.top().node_id][i];
				if(wall[Q.top().node_id][next])continue;

				int next_cost = Q.top().sum_cost+1;

				if(min_dist[next] > next_cost){
					min_dist[next] = next_cost;
					Q.push(Info(next,next_cost));
				}
			}
			Q.pop();
		}
	}

	return BIG_NUM;
}


int main(){

	scanf("%d %d %d",&W,&H,&N);

	int index = 0;
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			index_table[row][col] = index++;
		}
	}

	num_nodes = H*W;
	for(int i = 0; i < num_nodes; i++){
		for(int k = 0; k < num_nodes; k++){

			wall[i][k] = false;
		}
	}

	int s_col,s_row,d_col,d_row;
	int from_index,to_index;

	for(int loop = 0; loop < N; loop++){

		scanf("%d %d %d %d",&s_col,&s_row,&d_col,&d_row);

		if(s_col == d_col){ //縦

			if(s_col == 0){
				continue;
			}

			for(int i = min(s_row,d_row); i < max(s_row,d_row); i++){

				from_index = index_table[i][s_col-1];
				to_index = index_table[i][s_col];

				wall[from_index][to_index] = true;
				wall[to_index][from_index] = true;
			}

		}else{ //横

			if(s_row == 0){
				continue;
			}

			for(int i = min(s_col,d_col); i < max(s_col,d_col); i++){

				from_index = index_table[s_row-1][i];
				to_index = index_table[s_row][i];

				wall[from_index][to_index] = true;
				wall[to_index][from_index] = true;
			}
		}
	}

	int start_col,start_row;
	int goal_col,goal_row;

	scanf("%d %d",&start_col,&start_row);
	start = index_table[start_row][start_col];

	scanf("%d %d",&goal_col,&goal_row);
	goal = index_table[goal_row][goal_col];

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			from_index = index_table[row][col];

			for(int i = 0; i < 4; i++){
				int adj_row = row+diff_row[i];
				int adj_col = col+diff_col[i];
				if(!rangeCheck(adj_row,adj_col))continue;

				to_index = index_table[adj_row][adj_col];
				if(wall[from_index][to_index])continue;

				G[from_index].push_back(to_index);
			}
		}
	}

	calc_rev();
	int first_ans = func();
	for(int i = 0; i < num_nodes; i++){

		MIN_DIST[i] = min_dist[i];
	}

	int ans = 0;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			from_index = index_table[row][col];
			if(MIN_DIST[from_index]+rev_min_dist[from_index] != first_ans)continue; //最短経路上でないならSKIP

			for(int i = 0; i < 4; i++){

				int adj_row = row+diff_row[i];
				int adj_col = col+diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;
				to_index = index_table[adj_row][adj_col];

				if(wall[from_index][to_index])continue;
				wall[from_index][to_index] = true;

				int tmp_ans = func();
				if(tmp_ans != BIG_NUM){

					ans = max(ans,tmp_ans-first_ans);
				}

				wall[from_index][to_index] = false;
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 10812