There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of.


-----Input-----

Each of the three lines of the input contains two integers. The i-th line contains integers x_{i} and y_{i} ( - 10^9 ≤ x_{i}, y_{i} ≤ 10^9) — the coordinates of the i-th point. It is guaranteed that all points are distinct.


-----Output-----

Print a single number — the minimum possible number of segments of the polyline.


-----Examples-----
Input
1 -1
1 1
1 2

Output
1

Input
-1 -1
-1 3
4 3

Output
2

Input
1 1
2 3
3 2

Output
3



-----Note-----

The variant of the polyline in the first sample: [Image] The variant of the polyline in the second sample: $1$ The variant of the polyline in the third sample: $\because$

Difficulty: interview

Starter code:

Solutions:
a, b = list(map(int, input().split(' ')))
c, d = list(map(int, input().split(' ')))
e, f = list(map(int, input().split(' ')))
x=[[a, b],[c,d],[e,f]]
x.sort()
a, b, c, d, e, f = x[0][0], x[0][1], x[1][0], x[1][1], x[2][0], x[2][1]
if (a==c==e or b==d==f):
    print(1)
    quit()

if a == c:
    if b<f<d:
        print(3)
        quit()
    print(2)
    quit()

if c == e:
    if (d<b<f):
        print(3)
        quit()
    print(2)
    quit()

if b == d:
    print(2)
    quit()

if d == f:
    print(2)
    quit()

if b == f:
    if a<c<e:
        print(3)
        quit()
    print(2)
    quit()

print(3)
quit()


A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

def out(value):
    print(value)
    return

if A[0] == B[0] and B[0] == C[0]:
    out(1)

if A[1] == B[1] and B[1] == C[1]:
    out(1)

import itertools

X = A
Y = B
Z = C
for p in itertools.permutations([X, Y, Z]):
    A = p[0]
    B = p[1]
    C = p[2]
    if A[0] == B[0] and (C[1] <= min(A[1], B[1]) or C[1] >= max(A[1], B[1])):
        out(2)
    if A[1] == B[1] and (C[0] <= min(A[0], B[0]) or C[0] >= max(A[0], B[0])):
        out(2)

out(3)


ax, ay = list(map(int, input().split()))
bx, by = list(map(int, input().split()))
cx, cy = list(map(int, input().split()))
if (ax == bx == cx)or(ay == by == cy):
    ans = 1
elif (ax == bx)and((cy <= min(ay, by))or(cy >= max(ay, by))):
    ans = 2
elif (ax == cx)and((by <= min(ay, cy))or(by >= max(ay, cy))):
    ans = 2
elif (cx == bx)and((ay <= min(cy, by))or(ay >= max(cy, by))):
    ans = 2
elif (ay == by)and((cx <= min(ax, bx))or(cx >= max(ax, bx))):
    ans = 2
elif (ay == cy)and((bx <= min(ax, cx))or(bx >= max(ax, cx))):
    ans = 2
elif (cy == by)and((ax <= min(cx, bx))or(ax >= max(cx, bx))):
    ans = 2
else:
    ans = 3
print(ans)


read = lambda: list(map(int, input().split()))
x1, y1 = read()
x2, y2 = read()
x3, y3 = read()
ans = 3
f1 = y1 == y2 and ((x3 >= x2 and x3 >= x1) or (x3 <= x2 and x3 <= x1))
f2 = y2 == y3 and ((x1 >= x2 and x1 >= x3) or (x1 <= x2 and x1 <= x3))
f3 = y1 == y3 and ((x2 >= x3 and x2 >= x1) or (x2 <= x1 and x2 <= x3))
f4 = x1 == x2 and ((y3 >= y2 and y3 >= y1) or (y3 <= y2 and y3 <= y1))
f5 = x2 == x3 and ((y1 >= y2 and y1 >= y3) or (y1 <= y2 and y1 <= y3))
f6 = x1 == x3 and ((y2 >= y3 and y2 >= y1) or (y2 <= y1 and y2 <= y3))
if f1 or f2 or f3 or f4 or f5 or f6: ans = 2
if x1 == x2 == x3 or y1 == y2 == y3: ans = 1
print(ans)


#!/usr/bin/env python3

x1, y1 = input().split()
x2, y2 = input().split()
x3, y3 = input().split()
x1, y1, x2, y2, x3, y3 = int(x1), int(y1), int(x2), int(y2), int(x3), int(y3)

def ans(p1, p2, p3):
	x1, y1 = p1
	x2, y2 = p2
	x3, y3 = p3
	# x,x    x
	# x  x   x
	if (x1 == x2 == x3): return 1

	#  x  x
	#  x
	if (x1, y1) == (x2, y3): 
		return 2

	if y1 == y2:
		if x1 < x3 < x2: 
			# x   x
			#   x  
			return 3
		if x2 < x3 < x1:
			return 3
		else:
			# 	  x x
			# x
			return 2

	return 3

p1 = (x1, y1)
p2 = (x2, y2)
p3 = (x3, y3)

t1 = (y1, x1)
t2 = (y2, x2)
t3 = (y3, x3)
print(min(
	ans(p1, p2, p3),
	ans(p1, p3, p2),
	ans(p2, p1, p3),
	ans(p2, p3, p1),
	ans(p3, p1, p2),
	ans(p3, p2, p1),
	ans(t1, t2, t3),
	ans(t1, t3, t2),
	ans(t2, t1, t3),
	ans(t2, t3, t1),
	ans(t3, t1, t2),
	ans(t3, t2, t1)
))

p = [0]*3
q = [0]*3

sum = 0

a1,b1 = list(map(int, input().split()))
a2,b2 = list(map(int, input().split()))
if a1 == a2:
    p[0] = 1
if b1 == b2:
    q[0] = 1
a3,b3 = list(map(int, input().split()))    
if a1 == a3:
    p[1] = 1
if b1 == b3:
    q[1] = 1
if a2 == a3:
    p[2] = 1
if b2 == b3:
    q[2] = 1

sum = 0
for i in range(3):
    sum += p[i] + q[i]

if sum == 0:
    print(3)
elif sum == 3:
    print(1)
elif sum == 2:
    print(2)
else:
    if q[1] + q[2] + q[0] == 1:
        b1 = a1
        b2 = a2
        b3 = a3
        p[0] = q[0]
        p[1] = q[1]
        p[2] = q[2]

    if p[0] == 1 and (b3 > max(b1,b2) or b3 < min(b1,b2)):
        print(2)
    elif p[1] == 1 and (b2 > max(b1,b3) or b2 < min(b1,b3)):
        print(2)
    elif p[2] == 1 and (b1 > max(b2,b3) or b1 < min(b2,b3)):
        print(2)
    else:
        print(3)
        
            














                


read = lambda: list(map(int, input().split()))

def test(a, b, c):
	if a > b:
		a, b = b, a
	if not (a <= c <= b):
		return -1
	return 1 if c == a or c == b else 0

def main():
	a = [tuple(read()) for _ in range(3)]
	if a[0][0] == a[1][0] == a[2][0] or a[0][1] == a[1][1] == a[2][1]:
		return 1
	for i in range(3):
		for j in range(i + 1, 3):
			if a[i][0] != a[j][0] and a[i][1] != a[j][1]:
				k = 3 ^ i ^ j
				x = test(a[i][0], a[j][0], a[k][0])
				y = test(a[i][1], a[j][1], a[k][1])
				if min(x, y) >= 0 and max(x, y) == 1:
					return 2
	return 3

print(main())


x = [0 for i in range(3)]
y = [0 for i in range(3)]
mark = [False, False, False]
mark1 = [False, False, False]
for i in range(3):
    x[i], y[i] = list(map(int, input().split()))

xp = []
yp = []
for i in range(3):
    for j in range(i + 1, 3):
        if x[i] == x[j]:
            xp.append([i, j])
            mark[i] = True
            mark[j] = True
        if y[j] == y[i]:
            yp.append([i, j])
            mark1[i] = True
            mark1[j] = True            
if len(xp) == 3 or len(yp) == 3:
    print(1)
elif len(xp) == 1:
    if not mark[0]:
        if y[0] >= max(y[1], y[2]) or y[0] <= min(y[1], y[2]):
            print(2)
        else:
            print(3)
    elif not mark[1]:
        if y[1] >= max(y[0], y[2]) or y[1] <= min(y[0], y[2]):
            print(2)
        else:
            print(3)
    if not mark[2]:
        if y[2] >= max(y[1], y[0]) or y[2] <= min(y[1], y[0]):
            print(2)
        else:
            print(3)    
        
elif len(yp) == 1:
    if not mark1[0]:
        if x[0] >= max(x[1], x[2]) or x[0] <= min(x[1], x[2]):
            print(2)
        else:
            print(3)
    elif not mark1[1]:
        if x[1] >= max(x[0], x[2]) or x[1] <= min(x[0], x[2]):
            print(2)
        else:
            print(3)
    if not mark1[2]:
        if x[2] >= max(x[1], x[0]) or x[2] <= min(x[1], x[0]):
            print(2)
        else:
            print(3)    
else:
    print(3)



xs , ys = input().split(" ")
x1 = int(xs)
y1 = int(ys)

xs , ys = input().split(" ")
x2 = int(xs)
y2 = int(ys)

xs , ys = input().split(" ")
x3 = int(xs)
y3 = int(ys)


def check ( a , b , c ) :
  if a < b and b < c :
    return 3
  if c < b and b < a :
    return 3
  return 2

if x1 == x2 == x3 or y1 == y2 == y3 :
  print ( 1 )
  return  

if x2 == x3 :
  print ( check ( y2 , y1 , y3 ) )
  return
if x1 == x3 :
  print ( check ( y1 , y2 , y3 ) )
  return
if x1 == x2 :
  print ( check ( y1 , y3 , y2 ) )
  return

if y2 == y3 :
  print ( check ( x2 , x1 , x3 ) )
  return
if y1 == y3 :
  print ( check ( x1 , x2 , x3 ) )
  return
if y1 == y2 :
  print ( check ( x1 , x3 , x2 ) )
  return


  
print ( 3 ) 

#!/usr/bin/env python3
import operator
from itertools import islice
import math


def all_on_same_line(points):
    return all(x == points[0][0] for x, y in points) or all(y == points[0][1] for x, y in points)


def all_on_different_lines(points):
    return len(set(x for x, y in points)) == len(points) and len(set(y for x, y in points)) == len(points)


def has_two_points_with_same_x_coord(points):
    return len(set(x for x, y in points)) == 2


def get_common_x(points):
    xs = [x for x, y in points]
    for xx in set(x for x, y in points):
        if xs.count(xx) == 2:
            return xx

def get_common_y(points):
    ys = [y for x, y in points]
    for yy in set(y for x, y in points):
        if ys.count(yy) == 2:
            return yy


def main():
    points = [(int(x), int(y)) for x, y in (input().split() for _ in range(3))]
    if all_on_same_line(points):
        print(1)
    elif all_on_different_lines(points):
        print(3)
    else:
        if has_two_points_with_same_x_coord(points):
            y = get_common_x(points)
            points = sorted(points, key=lambda p: p[0] == y)
            if min(points[1][1], points[2][1]) < points[0][1] <  max(points[1][1], points[2][1]):
                print(3)
            else:
                print(2)
        else:
            y = get_common_y(points)
            points = sorted(points, key=lambda p: p[1] == y)
            if min(points[1][0], points[2][0]) < points[0][0] <  max(points[1][0], points[2][0]):
                print(3)
            else:
                print(2)


def __starting_point():
    main()

__starting_point()

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

if (a[0] == b[0] and b[0] == c[0]) or (a[1] == b[1] and b[1] == c[1]):
    print(1)
    return

if (a[0] == b[0] and ((c[1] >= a[1] and c[1] >= b[1]) or (c[1] <= a[1] and c[1] <= b[1]))) or \
   (a[0] == c[0] and ((b[1] >= a[1] and b[1] >= c[1]) or (b[1] <= a[1] and b[1] <= c[1]))) or \
   (c[0] == b[0] and ((a[1] >= c[1] and a[1] >= b[1]) or (a[1] <= b[1] and a[1] <= c[1]))) or \
   (a[1] == b[1] and ((c[0] >= a[0] and c[0] >= b[0]) or (c[0] <= a[0] and c[0] <= b[0]))) or \
   (a[1] == c[1] and ((b[0] >= a[0] and b[0] >= c[0]) or (b[0] <= a[0] and b[0] <= c[0]))) or \
   (b[1] == c[1] and ((a[0] >= c[0] and a[0] >= b[0]) or (a[0] <= b[0] and a[0] <= c[0]))):
    print(2)
    return

print(3)

ps = [tuple(int(x) for x in input().split()) for _ in range(3)]
ps.sort()
xa, ya = ps[0]
xb, yb = ps[1]
xc, yc = ps[2]
if xa == xb:
    if xc == xa:
        print(1)
    elif yc <= ya or yb <= yc:
            print(2)
    else:
        print(3)
elif ya == yb:
    if yc == ya:
        print(1)
    else:
        print(2)
elif ya < yb:
    if xb == xc or yb == yc:
        print(2)
    else:
        print(3)
else:
    if yb == yc or (xb == xc and yc <= ya):
        print(2)
    else:
        print(3)


x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())
def det(x0,y0,x1,y1):
    return x0*y1


if x1==x2==x3 or y1==y2==y3:
    print(1)
    quit()
elif       (y1==y2 and ((x3<=x1 and x3<=x2) or (x3>=x1 and x3>=x2)))\
        or (y1==y3 and ((x2<=x1 and x2<=x3) or (x2>=x1 and x2>=x3)))\
        or (y2==y3 and ((x1<=x2 and x1<=x3) or (x1>=x2 and x1>=x3)))\
        or (x1==x2 and ((y3<=y1 and y3<=y2) or (y3>=y1 and y3>=y2)))\
        or (x1==x3 and ((y2<=y1 and y2<=y3) or (y2>=y1 and y2>=y3)))\
        or (x2==x3 and ((y1<=x2 and y1<=y3) or (y1>=y2 and y1>=y3))):
    print(2)
    quit()

else:
    print(3)

p = [tuple(map(int, input().split())) for i in range(3)]
if p[0][0] == p[1][0] and p[1][0] == p[2][0] or p[0][1] == p[1][1] and p[1][1] == p[2][1]:
     print(1)
     return
p.sort()
if p[0][0] == p[1][0]:
     print(3 if p[2][1] in range(min(p[0][1], p[1][1]) + 1, max(p[0][1], p[1][1])) else 2)
     return
if p[1][0] == p[2][0]:
     print(3 if p[0][1] in range(min(p[1][1], p[2][1]) + 1, max(p[1][1], p[2][1])) else 2)
     return
p = sorted((y, x) for (x, y) in p)
if p[0][0] == p[1][0]:
     print(3 if p[2][1] in range(min(p[0][1], p[1][1]) + 1, max(p[0][1], p[1][1])) else 2)
     return
if p[1][0] == p[2][0]:
     print(3 if p[0][1] in range(min(p[1][1], p[2][1]) + 1, max(p[1][1], p[2][1])) else 2)
     return
print(3)

points = [tuple(int(x) for x in input().split()) for _ in range(3)]
points.sort()
p1, p2, p3 = points

if (p1[0] == p2[0] and p2[0] == p3[0]) or (p1[1] == p2[1] and p2[1] == p3[1]):
    print(1)
elif p1[0] == p2[0]:
    if min(p1[1], p2[1]) < p3[1] < max(p1[1], p2[1]):
        print(3)
    else:
        print(2)
elif p2[0] == p3[0]:
    if min(p2[1], p3[1]) < p1[1] < max(p2[1], p3[1]):
        print(3)
    else:
        print(2)
else:
    points.sort(key=lambda p: p[1])
    if p1[1] == p2[1]:
        if min(p1[0], p2[0]) < p3[0] < max(p1[0], p2[0]):
            print(3)
        else:
            print(2)
    elif p2[1] == p3[1]:
        if min(p2[0], p3[0]) < p1[0] < max(p1[0], p2[0]):
            print(3)
        else:
            print(2)
    else:
        print(3)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

x = []
y = []

for i in range(3):
    (a, b)   = (int(i) for i in input().split())
    x.append(a)
    y.append(b)

if len(set(x)) == 2:
    (x, y) = (y, x)

a = [ [x[i], y[i]] for i in range(3) ]
a = sorted(a)

start = time.time()

if (a[0][0] == a[1][0] and a[1][0] == a[2][0]) or (a[0][1] == a[1][1] and a[1][1] == a[2][1]):
    print(1)
elif a[0][0] == a[1][0] or a[1][0] == a[2][0] or a[0][1] == a[1][1] or a[1][1] == a[2][1] :
    print(2)
else:
    print(3)

finish = time.time()
#print(finish - start)


#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

def calc(x1, y1, x2, y2, x3, y3):
    if x1 == x2 == x3 or y1 == y2 == y3:
        return 1

    if x2 == x3 or y2 == y3:
        x1, x3 = x3, x1
        y1, y3 = y3, y1
    if x1 == x3 or y1 == y3:
        x2, x3 = x3, x2
        y2, y3 = y3, y2

    if x1 == x2:
        if y1 < y3 < y2 or y2 < y3 < y1:
            return 3
        else:
            return 2

    if y1 == y2:
        if x1 < x3 < x2 or x2 < x3 < x1:
            return 3
        else:
            return 2

    return 3    

x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
x3, y3 = [int(i) for i in input().split()]

print(calc(x1, y1, x2, y2, x3, y3))


import math
onsegment = lambda x, y, z: min(y,z) <= x <= max(y,z)
oninterval = lambda x, y, z: min(y,z) < x < max(y,z)
def inrectangle(p0, p1, p2):
    return oninterval(p0[0], p1[0], p2[0]) and oninterval(p0[1], p1[1], p2[1])
def onborder(p0, p1, p2):
    return onsegment(p0[0], p1[0], p2[0]) and onsegment(p0[1], p1[1], p2[1]) and not inrectangle(p0, p1, p2)
points = []
for i in range(3):
    points.append(tuple(int(x) for x in input().split()))
points.sort()
if (all((point[0] == points[0][0] for point in points)) or
    all((point[1] == points[0][1] for point in points))):
    print(1)
elif points[0][1] == points[2][1]:
    print(3 if points[0][0] < points[1][0] < points[2][0] else 2)
elif onborder(points[1], points[0], points[2]) or onborder(points[2], points[0], points[1]) or onborder(points[0], points[1], points[2]):
    print(2)
else:
    print(3)


x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
xs = [x1, x2, x3]
ys = [y1, y2, y3]
ycount = 1
xcount = 1
for i in range(3):
	xcount = max(xcount, xs.count(xs[i]))
	ycount = max(ycount, ys.count(ys[i]))
ret = 3
if xcount == 3 or ycount == 3:
	print(1)
elif xcount == 2 or ycount == 2:
	if xcount == 2:
		for i in range(2):
			for j in range(i+1, 3):
				if xs[i] == xs[j]:
					a = i
					b = j
		for i in range(3):
			if i != a and i != b:
				c = i
		if ys[a] < ys[c] < ys[b] or ys[a] > ys[c] > ys[b]:
			ret = 3
		else:
			ret = 2
	if ycount == 2:
		for i in range(2):
			for j in range(i+1, 3):
				if ys[i] == ys[j]:
					a = i
					b = j
		for i in range(3):
			if i != a and i != b:
				c = i
		if xs[a] < xs[c] < xs[b] or xs[a] > xs[c] > xs[b]:
			ret = min(ret, 3)
		else:
			ret = min(ret, 2)
	print(ret)
else:
	print(ret)



x = [0, 0, 0]
y = [0, 0, 0]

def bet(a, b, c):
    return a <= c <= b or b <= c <= a

def f(i, j, k):
    return (x[k] == x[i] or x[k] == x[j]) and bet(y[i], y[j], y[k]) or (y[k] == y[i] or y[k] == y[j]) and bet(x[i], x[j], x[k])

for i in range(3):
    xi, yi = list(map(int, input().split()))
    x[i] = xi
    y[i] = yi

if (x[0] == x[1] == x[2] or y[0] == y[1] == y[2]):
    print(1)
elif f(0, 1, 2) or f(0, 2, 1) or f(1, 2, 0):
    print(2)
else:
    print(3)


def is_parallel(p1, p2):
    if p1[0] == p2[0]:
        return 1
    if p1[1] == p2[1]:
        return 2
    return 0

a = [list(map(int, input().split())) for _ in range(3)]

all_the_same = is_parallel(a[0], a[1]) == is_parallel(a[1], a[2]) == is_parallel(a[0], a[2])
first_and_second = is_parallel(a[0], a[1])
if all_the_same:
    if first_and_second != 0:
        print(1)
        return
    else:
        print(3)
else:
    new_points = []

    for i in range(3):
        if is_parallel(a[i], a[(i+1) % 3]):
            for j in range(3):
                new_points.append(a[(i + j) % 3])
            break

    if len(new_points) == 0:
        print(3)
        return

    if is_parallel(*new_points[:2]) == 2:
        for i in range(3):
            new_points[i][0], new_points[i][1] = new_points[i][1], new_points[i][0]

    if new_points[0][1] > new_points[1][1]:
        new_points[0], new_points[1] = new_points[1], new_points[0]

    if new_points[2][1] <= new_points[0][1] <= new_points[1][1]:
        print(2)
    elif new_points[0][1] <= new_points[1][1] <= new_points[2][1]:
        print(2)
    else:
        print(3)

#!/usr/bin/env python3

from collections import namedtuple
from itertools   import permutations

Point = namedtuple("Point", "x y")

try:
    while True:
        p = [Point(*list(map(int, input().split()))) for i in range(3)]
        a, b, c = p
        if a.x == b.x == c.x or a.y == b.y == c.y:
            print(1)
        else:
            for a, b, c in permutations(p):
                if a.x == b.x and not a.y < c.y < b.y and not b.y < c.y < a.y:
                    print(2)
                    break
                if a.y == b.y and not a.x < c.x < b.x and not b.x < c.x < a.x:
                    print(2)
                    break
            else:
                print(3)

except EOFError:
    pass


x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())
if x1==x2==x3 or y1==y2==y3:
    print(1)
    quit()
elif  (y1==y2 and ((x3<=x1 and x3<=x2) or (x3>=x1 and x3>=x2)))\
        or (y1==y3 and ((x2<=x1 and x2<=x3) or (x2>=x1 and x2>=x3)))\
        or (y2==y3 and ((x1<=x2 and x1<=x3) or (x1>=x2 and x1>=x3)))\
        or (x1==x2 and ((y3<=y1 and y3<=y2) or (y3>=y1 and y3>=y2)))\
        or (x1==x3 and ((y2<=y1 and y2<=y3) or (y2>=y1 and y2>=y3)))\
        or (x2==x3 and ((y1<=x2 and y1<=y3) or (y1>=y2 and y1>=y3))):
    print(2)
    quit()
else:print(3)

x = [0] * 3
y = [0] * 3
for i in range(3):
    x[i], y[i] = map(int,input().split())

if x[0] == x[1] == x[2] or y[0] == y[1] == y[2]:
    print(1)
elif x[0] == x[1] and (y[2]>=max(y[0],y[1]) or y[2]<=min(y[0],y[1])): print(2)
elif x[0] == x[2] and (y[1]>=max(y[0],y[2]) or y[1]<=min(y[0],y[2])): print(2)
elif x[1] == x[2] and (y[0]>=max(y[1],y[2]) or y[0]<=min(y[1],y[2])): print(2)
elif y[0] == y[1] and (x[2]>=max(x[0],x[1]) or x[2]<=min(x[0],x[1])): print(2)
elif y[0] == y[2] and (x[1]>=max(x[0],x[2]) or x[1]<=min(x[0],x[2])): print(2)
elif y[1] == y[2] and (x[0]>=max(x[1],x[2]) or x[0]<=min(x[1],x[2])): print(2)

else: print(3)

p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p = [p1, p2, p3]
if (p1[0]==p2[0] and p2[0]==p3[0]) or (p1[1]==p2[1] and p2[1]==p3[1]):
	print(1)
else:
	for i in range(3):
		for j in range(3):
			for k in range(3):
				if (i != j) and (j!=k) and(i!=k):
					#print(i,j,k)
					for z in range(2):
						z2 = 1-z
						if (p[i][z] == p[j][z]) and not(min(p[i][z2],p[j][z2]) < p[k][z2] < max(p[i][z2],p[j][z2])):
							print(2)
							return
	print(3)