CF-101466-C

Lately the communication between planets has been an important issue, which is why the Earth has made many efforts to be connected to every other planet in the universe.

The Universal Network Army of Lasers (UNAL) is trying to connect the Earth with other planets in the universe. In order to make this, the UNAL uses a laser machine which each time it is used, it sends a communication signal in the form of a ray of light in the direction of the planet.

This laser machine is so powerful, that a ray of light generated by it is capable to cross all the planets it touches until the end of the universe. Moreover, when it fires a ray of light in one direction it also fires a ray of light in the opposite direction.

Given the coordinates of all the planets in the universe, help the UNAL to design the way to communicate the Earth with all other planets in the universe using the machine the minimum number of times.

Input

The first line of input contains one integer n (1 ≤ n ≤ 5000), the number of planets.
The next n lines contains the list of coordinates of the planets. In particular, the i - th line contains three integers xi, yi, zi ( - 109 ≤ xi, yi, zi ≤ 109), the coordinates of the i - th planet, respectively. The Earth is the first planet on the list. It is guaranteed that all the planets have different coordinates.

Output

Output a single integer, the minimun number of times the machine should be used to communicate the Earth with all other planets in the universe

Examples

Input

3
0 0 0
1 1 0
-1 -1 0

Output

1

Input

4
0 0 0
1 0 0
0 1 0
0 0 1

Output

3


题意:

从地球向外发射激光,能穿透一切,每次发射的激光都是双向的,即直线而不是射线。
nn个星球(包括地球)问需要多少激光。
输入n然后n个三维坐标

做法:

每次输入一个点都变成一个以地球为起点,当前点为终点的向量
然后在一个一开始为空的vector<向量>中for 每个向量,如果没有与之共线的向量则放入这个数组
否则跳过,这样vector的size即为需要的激光数。
PS:向量共线坐标判断:
在一个平面内

{a1=(x1,y1)a2=(x2,y2)\begin{cases} \mathbf{\vec{a_1}}=(x_1,y_1)\\\mathbf{\vec{a_2}}=(x_2,y_2) \end{cases}

if a1a2\text{if}\quad\ \mathbf{\vec{a_1}}\vert\vert\mathbf{\vec{a_2}}

x1×y2=x2×y1x_1\times y_2 = x_2 \times y_1

空间内就是三个平面的分解向量分别平行

{a1=(x1,y1,z1)a2=(x2,y2,z2)\begin{cases} \mathbf{\vec{a_1}}=(x_1,y_1,z_1)\\\mathbf{\vec{a_2}}=(x_2,y_2,z_2) \end{cases}

if a1a2\text{if}\quad\ \mathbf{\vec{a_1}}\vert\vert\mathbf{\vec{a_2}}

{x1×y2=x2×y1y1×z2=y2×z1z1×x2=z2×x1\begin{cases} x_1\times y_2 = x_2 \times y_1 \\ y_1\times z_2 = y_2 \times z_1 \\ z_1\times x_2 = z_2 \times x_1 \end{cases}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct point
{
ll x, y, z;
bool paralel(const point& b)
{
if (x*b.y == y * b.x)
if (x*b.z == b.x*z)
if (y*b.z == b.y*z)
return true;
return false;
}
};
vector<point>v;
int main()
{
int n;
cin >> n;
v.clear();
point earth;
cin >> earth.x >> earth.y >> earth.z;
point t;
for (int i = 1; i < n; i++)
{
cin >> t.x >> t.y >> t.z;
t.x -= earth.x;
t.y -= earth.y;
t.z -= earth.z;
bool flag = true;
for (int j = 0; j < v.size(); j++)
{
if (t.paralel(v[j]))
{
flag = false;
break;
}
}
if (flag)
v.push_back(t);
}
cout << v.size() << endl;
}