> File Name: 1066.cpp
> Author: jiangyuzhu
> Mail: 834138558@qq.com
> Created Time: 2016/9/16 11:03:53
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 30 + 5;
double eps = 1e-8;
double add(double a, double b)
{
if(abs(a + b) < eps * (abs(a) + abs(b))) return 0;
else return a + b;
}
struct P{
double x, y;
P() {}
P(double x, double y) : x(x), y(y){}
P operator + (P p){
return P(add(x, p.x), add(y, p.y));
}
P operator -(P p){
return P(add(x, -p.x), add(y, -p.y));
}
double dot(P p){
return add(x * p.x, y *p.y);
}
double det(P p){
return add(x * p.y, - y * p.x);
}
P operator *(double d){
return P(x * d, y * d);
}
}p[maxn << 1];
P des;
bool onseg(P p1, P p2, P q)
{
return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}
P intersection(P p1, P p2, P q1, P q2)
{
return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}
int main (void)
{
int n;scanf("%d", &n);
for(int i = 0; i < 2 * n; i++){
scanf("%lf%lf", &p[i].x, &p[i].y);
}
int ans, res = n + 1;
double x, y;scanf("%lf%lf", &des.x, &des.y);
for(int i = 0; i < 2 * n; ++i){
ans = 1;
for(int j = 0; j < 2 * n; j += 2){
if(j == i || j == i - 1) continue;
P tmp = intersection(p[i], des, p[j], p[j + 1]);
ans += onseg(p[j], p[j + 1], tmp) && onseg(p[i], des, tmp);
}
res = min(res, ans);
}
printf("Number of doors = %d\n", res);
return 0;
}