import
java.lang.*;
import
java.util.*;
class
GFG{
static
class
pair
{
int
x, y;
pair(
int
x,
int
y)
{
this
.x = x;
this
.y = y;
}
@Override
public
int
hashCode()
{
return
this
.x;
}
@Override
public
boolean
equals(Object obj)
{
if
(
this
== obj)
return
true
;
if
(obj ==
null
||
obj.getClass() !=
this
.getClass())
return
false
;
pair geek = (pair) obj;
return
(geek.x ==
this
.x &&
geek.y ==
this
.y);
}
}
static
int
gcd(
int
a,
int
b)
{
if
(b ==
0
)
return
a;
return
gcd(b, a % b);
}
static
int
countUniqueFractions(
int
num[],
int
den[],
int
N)
{
Map<pair, Integer> mp =
new
HashMap<>();
for
(
int
i =
0
; i < N; i++)
{
if
(num[i] ==
0
)
{
pair tmp =
new
pair(
0
,
0
);
mp.put(tmp,
1
);
}
else
{
int
number = num[i] / gcd(num[i], den[i]);
int
denom = den[i] / gcd(num[i], den[i]);
if
(denom <
0
) number *= -
1
;
pair tmp =
new
pair(number, denom);
mp.put(tmp,
1
);
}
}
return
mp.size();
}
public
static
void
main (String[] args)
{
int
N =
6
;
int
num[] = {
1
,
40
,
20
,
5
,
6
,
7
};
int
den[] = {
10
,
40
,
2
,
5
,
12
,
14
};
System.out.print(countUniqueFractions(num, den, N));
}
}