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: MEDIUM_HARD
Tags: Implementation

Constructive algorithms

Starter code:

Solutions:
(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)


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


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
(x, y, z) = (1, 1, 0)
if a[0] == b[0] or a[0] == c[0] or b[0] == c[0]:
	x = 2
	if a[0] == b[0] and a[0] == c[0] and (b[0] == c[0]):
		x = 3
	elif a[0] == b[0]:
		if c[1] in range(min(a[1], b[1]), max(a[1], b[1])):
			z += 1
	elif a[0] == c[0]:
		if b[1] in range(min(a[1], c[1]), max(a[1], c[1])):
			z += 1
	elif b[0] == c[0]:
		if a[1] in range(min(b[1], c[1]), max(b[1], c[1])):
			z += 1
if a[1] == b[1] or a[1] == c[1] or b[1] == c[1]:
	y = 2
	if a[1] == b[1] and a[1] == c[1] and (b[1] == c[1]):
		y = 3
	elif a[1] == b[1]:
		if c[0] in range(min(a[0], b[0]), max(a[0], b[0])):
			z += 1
	elif a[1] == c[1]:
		if b[0] in range(min(a[0], c[0]), max(a[0], c[0])):
			z += 1
	elif b[1] == c[1]:
		if a[0] in range(min(b[0], c[0]), max(b[0], c[0])):
			z += 1
if x * y == 1:
	print(3)
elif x * y == 3:
	print(1)
elif x * y == 4:
	print(2)
elif z == 1:
	print(3)
else:
	print(2)


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()


(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)


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):
					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)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = 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)


from collections import namedtuple
Point = namedtuple('Pont', ['x', 'y'])

def f(p1, p2, p3):
	if p1.x == p2.x and (p3.y >= max(p1.y, p2.y) or p3.y <= min(p1.y, p2.y)):
		return True
	if p1.y == p2.y and (p3.x >= max(p1.x, p2.x) or p3.x <= min(p1.x, p2.x)):
		return True
	return False
(x1, y1) = [int(x) for x in input().split()]
(x2, y2) = [int(x) for x in input().split()]
(x3, y3) = [int(x) for x in input().split()]
p1 = Point(x=x1, y=y1)
p2 = Point(x=x2, y=y2)
p3 = Point(x=x3, y=y3)
if p1.x == p2.x and p2.x == p3.x or (p1.y == p2.y and p2.y == p3.y):
	print(1)
elif f(p1, p2, p3) or f(p1, p3, p2) or f(p2, p3, p1):
	print(2)
else:
	print(3)


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)


import sys
from math import gcd, sqrt, ceil, log2
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
import math
sys.setrecursionlimit(2 * 10 ** 5 + 10)
import heapq
from itertools import permutations
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
aa = 'abcdefghijklmnopqrstuvwxyz'

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_sum(bit, i):
	s = 0
	i += 1
	while i > 0:
		s += bit[i]
		i -= i & -i
	return s

def update(bit, n, i, v):
	i += 1
	while i <= n:
		bit[i] += v
		i += i & -i

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def primeFactors(n):
	sa = []
	while n % 2 == 0:
		sa.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			sa.append(i)
			n = n // i
	if n > 2:
		sa.append(n)
	return sa

def seive(n):
	pri = [True] * (n + 1)
	p = 2
	while p * p <= n:
		if pri[p] == True:
			for i in range(p * p, n + 1, p):
				pri[i] = False
		p += 1
	return pri

def check_prim(n):
	if n < 0:
		return False
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def getZarr(string, z):
	n = len(string)
	(l, r, k) = (0, 0, 0)
	for i in range(1, n):
		if i > r:
			(l, r) = (i, i)
			while r < n and string[r - l] == string[r]:
				r += 1
			z[i] = r - l
			r -= 1
		else:
			k = i - l
			if z[k] < r - i + 1:
				z[i] = z[k]
			else:
				l = i
				while r < n and string[r - l] == string[r]:
					r += 1
				z[i] = r - l
				r -= 1

def search(text, pattern):
	concat = pattern + '$' + text
	l = len(concat)
	z = [0] * l
	getZarr(concat, z)
	ha = []
	for i in range(l):
		if z[i] == len(pattern):
			ha.append(i - len(pattern) - 1)
	return ha

def mergeIntervals(arr):
	arr.sort(key=lambda x: x[0])
	m = []
	s = -10000
	max = -100000
	for i in range(len(arr)):
		a = arr[i]
		if a[0] > max:
			if i != 0:
				m.append([s, max])
			max = a[1]
			s = a[0]
		elif a[1] >= max:
			max = a[1]
	if max != -100000 and [s, max] not in m:
		m.append([s, max])
	return m

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def sol(n):
	seti = set()
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			seti.add(n // i)
			seti.add(i)
	return seti

def lcm(a, b):
	return a * b // gcd(a, b)

def moore_voting(l):
	count1 = 0
	count2 = 0
	first = 10 ** 18
	second = 10 ** 18
	n = len(l)
	for i in range(n):
		if l[i] == first:
			count1 += 1
		elif l[i] == second:
			count2 += 1
		elif count1 == 0:
			count1 += 1
			first = l[i]
		elif count2 == 0:
			count2 += 1
			second = l[i]
		else:
			count1 -= 1
			count2 -= 1
	for i in range(n):
		if l[i] == first:
			count1 += 1
		elif l[i] == second:
			count2 += 1
	if count1 > n // 3:
		return first
	if count2 > n // 3:
		return second
	return -1

def find_parent(u, parent):
	if u != parent[u]:
		parent[u] = find_parent(parent[u], parent)
	return parent[u]

def dis_union(n):
	par = [i for i in range(n + 1)]
	rank = [1] * (n + 1)
	k = int(input())
	for i in range(k):
		(a, b) = map(int, input().split())
		(z1, z2) = (find_parent(a, par), find_parent(b, par))
		if z1 != z2:
			par[z1] = z2
			rank[z2] += rank[z1]

def dijkstra(n, tot, hash):
	hea = [[0, n]]
	dis = [10 ** 18] * (tot + 1)
	dis[n] = 0
	boo = defaultdict(bool)
	check = defaultdict(int)
	while hea:
		(a, b) = heapq.heappop(hea)
		if boo[b]:
			continue
		boo[b] = True
		for (i, w) in hash[b]:
			if b == 1:
				c = 0
				if (1, i, w) in nodes:
					c = nodes[1, i, w]
					del nodes[1, i, w]
				if dis[b] + w < dis[i]:
					dis[i] = dis[b] + w
					check[i] = c
				elif dis[b] + w == dis[i] and c == 0:
					dis[i] = dis[b] + w
					check[i] = c
			elif dis[b] + w <= dis[i]:
				dis[i] = dis[b] + w
				check[i] = check[b]
			heapq.heappush(hea, [dis[i], i])
	return check

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res *= x
		x = x * x
		y = y >> 1
	return res
l = []
(x1, x2) = map(int, input().split())
(x3, x4) = map(int, input().split())
(x5, x6) = map(int, input().split())
l.append([x1, x2])
l.append([x3, x4])
l.append([x5, x6])
l.sort()
if x1 == x3 == x5 or x2 == x4 == x6:
	print(1)
	exit()
flag = 0
z = permutations(l)
for i in z:
	(a, b, c) = i
	(x1, y1) = a
	(x2, y2) = b
	(x3, y3) = c
	if y1 == y2:
		(x1, x2) = (min(x1, x2), max(x1, x2))
		if x3 >= x2 or x3 <= x1:
			flag = 1
	if x1 == x2:
		(y1, y2) = (min(y1, y2), max(y1, y2))
		if y3 >= y2 or y3 <= y1:
			flag = 1
if flag == 1:
	print(2)
else:
	print(3)


read = lambda : 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)


def main():
	from sys import stdin
	(a, b, c, d, e, f) = map(int, stdin.read().split())
	if a == c == e or b == d == f:
		print(1)
		return
	else:
		for _ in (0, 1):
			for _ in range(3):
				if a == c and (not (b < f < d or b > f > d)):
					print(2)
					return
				(a, b, c, d, e, f) = (c, d, e, f, a, b)
			(a, b, c, d, e, f) = (b, a, d, c, f, e)
	print(3)
main()


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = map(int, input().split())
pts = [[x1, y1], [x2, y2], [x3, y3]]
nX = len(set([x1, x2, x3]))
nY = len(set([y1, y2, y3]))
perms = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
n = 3
for p in perms:
	npts = [pts[p[0]], pts[p[1]], pts[p[2]]]
	p0 = pts[p[0]]
	p1 = pts[p[1]]
	p2 = pts[p[2]]
	nl = 3
	if p0[0] == p1[0]:
		if p1[0] == p2[0]:
			nl = 1
		elif abs(p1[1] - p0[1]) <= abs(p2[1] - p0[1]):
			nl = min(2, nl)
		else:
			nl = min(3, nl)
	elif p0[1] == p1[1]:
		if p1[1] == p2[1]:
			nl = 1
		elif abs(p1[0] - p0[0]) <= abs(p2[0] - p0[0]):
			nl = min(2, nl)
		else:
			nl = min(3, nl)
	n = min(n, nl)
print(n)


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 : 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())


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
	(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)
		continue

	def f(x, y, z):
		return x <= min(y, z) or x >= max(y, z)
	if x1 == x2 and f(y3, y1, y2) or (x2 == x3 and f(y1, y2, y3)) or (x1 == x3 and f(y2, y1, y3)) or (y1 == y2 and f(x3, x1, x2)) or (y2 == y3 and f(x1, x2, x3)) or (y1 == y3 and f(x2, x1, x3)):
		print(2)
		continue
	print(3)


(a, b) = map(int, input().split(' '))
(c, d) = map(int, input().split(' '))
(e, f) = 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()


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)


def mezh(a, b, c):
	return min(a, b) <= c and c <= max(a, b)

def is_in_sqr(i, j, k):
	return (x[k] == x[i] or x[k] == x[j]) and mezh(y[i], y[j], y[k]) or ((y[k] == y[i] or y[k] == y[j]) and mezh(x[i], x[j], x[k]))
x = [0] * 3
y = [0] * 3
for i in range(3):
	(x[i], y[i]) = map(int, input().split())
if x[1] == x[0] == x[2] or y[1] == y[0] == y[2]:
	print('1')
elif is_in_sqr(0, 1, 2) or is_in_sqr(0, 2, 1) or is_in_sqr(1, 2, 0):
	print('2')
else:
	print('3')


(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
	if x1 == x2 == x3:
		return 1
	if (x1, y1) == (x2, y3):
		return 2
	if y1 == y2:
		if x1 < x3 < x2:
			return 3
		if x2 < x3 < x1:
			return 3
		else:
			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)))


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


(a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
if a[0] == b[0] == c[0] or a[1] == b[1] == c[1]:
	print(1)
elif a[1] == b[1] and (not (sorted([a[0], b[0], c[0]]).index(c[0]) == 1 and sorted([a[0], b[0], c[0]])[::-1].index(c[0]) == 1)) or (b[1] == c[1] and (not (sorted([a[0], b[0], c[0]]).index(a[0]) == 1 and sorted([a[0], b[0], c[0]])[::-1].index(a[0]) == 1))) or (a[1] == c[1] and (not (sorted([a[0], b[0], c[0]]).index(b[0]) == 1 and sorted([a[0], b[0], c[0]])[::-1].index(b[0]) == 1))) or (a[0] == b[0] and (not (sorted([a[1], b[1], c[1]]).index(c[1]) == 1 and sorted([a[1], b[1], c[1]])[::-1].index(c[1]) == 1))) or (b[0] == c[0] and (not (sorted([a[1], b[1], c[1]]).index(a[1]) == 1 and sorted([a[1], b[1], c[1]])[::-1].index(a[1]) == 1))) or (a[0] == c[0] and (not (sorted([a[1], b[1], c[1]]).index(b[1]) == 1 and sorted([a[1], b[1], c[1]])[::-1].index(b[1]) == 1))):
	print(2)
else:
	print(3)


from collections import defaultdict

def enquire(l):
	dict_x = defaultdict(list)
	dict_y = defaultdict(list)
	for i in l:
		dict_x[i[0]].append(i[1])
		dict_y[i[1]].append(i[0])
	dict_x = sorted(dict_x.items(), key=lambda x: len(x[1]))
	dict_y = sorted(dict_y.items(), key=lambda x: len(x[1]))
	if len(dict_x) == 1 or len(dict_y) == 1:
		return 1
	elif len(dict_x) == 2:
		y1 = max(dict_x[1][1][0], dict_x[1][1][1])
		y2 = min(dict_x[1][1][0], dict_x[1][1][1])
		y3 = dict_x[0][1][0]
		if y3 <= y2 or y3 >= y1:
			return 2
		elif y3 > y2 and y3 < y1:
			return 3
	elif len(dict_y) == 2:
		y1 = max(dict_y[1][1][0], dict_y[1][1][1])
		y2 = min(dict_y[1][1][0], dict_y[1][1][1])
		y3 = dict_y[0][1][0]
		if y3 <= y2 or y3 >= y1:
			return 2
		elif y3 > y2 and y3 < y1:
			return 3
	else:
		return 3
l = []
for i in range(3):
	l.append(list(map(int, input().split())))
print(enquire(l))


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)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = map(int, input().split())
px = [x1, x2, x3]
py = [y1, y2, y3]
x = set(px)
y = set(py)
if len(x) == 1 or len(y) == 1:
	print(1)
elif len(x) == 2 and len(y) == 2:
	print(2)
elif len(x) == 2:
	wanted = -1
	for i in range(3):
		if px.count(px[i]) == 1:
			wanted = i
	value = py[wanted]
	py.pop(wanted)
	if value > max(py) or value < min(py):
		print(2)
	else:
		print(3)
elif len(y) == 2:
	wanted = -1
	for i in range(3):
		if py.count(py[i]) == 1:
			wanted = i
	value = px[wanted]
	px.pop(wanted)
	if value > max(px) or value < min(px):
		print(2)
	else:
		print(3)
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)


(x, y) = map(int, input().split())
(u, v) = map(int, input().split())
(w, z) = map(int, input().split())
xs = sorted([x, u, w])
ys = sorted([y, v, z])
mx = 0
if xs[0] == xs[1] or xs[1] == xs[2]:
	if xs[0] == xs[1] and xs[1] == xs[2]:
		mx = 2
	else:
		mx = 1
my = 0
if ys[0] == ys[1] or ys[1] == ys[2]:
	if ys[0] == ys[1] and ys[1] == ys[2]:
		my = 2
	else:
		my = 1
if mx == 2 or my == 2:
	print(1)
	exit(0)
elif mx == 1:
	flag = True
	if x == u:
		if min(y, v) < z < max(y, v):
			flag = False
	elif x == w:
		if min(y, z) < v < max(y, z):
			flag = False
	elif u == w:
		if min(v, z) < y < max(v, z):
			flag = False
elif my == 1:
	flag = True
	if y == v:
		if min(x, u) < w < max(x, u):
			flag = False
	elif y == z:
		if min(x, w) < u < max(x, w):
			flag = False
	elif v == z:
		if min(u, w) < x < max(u, w):
			flag = False
else:
	flag = False
if flag:
	print(2)
else:
	print(3)


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

def check(x1, y1, x2, y2, x3, y3):
	if x1 == x3 and y2 == y3:
		return True
	if x2 == x3 and y1 == y3:
		return True
	if x1 == x2 and (not min(y1, y2) < y3 < max(y1, y2)):
		return True
	if y1 == y2 and (not min(x1, x2) < x3 < max(x2, x1)):
		return True
	return False

def chek2(x1, y1, x2, y2, x3, y3):
	if x1 == x2 == x3:
		return True
	if y1 == y2 == y3:
		return True
	return False
if chek2(x1, y1, x2, y2, x3, y3):
	print(1)
elif check(x1, y1, x2, y2, x3, y3) or check(x1, y1, x3, y3, x2, y2) or check(x2, y2, x3, y3, x1, y1):
	print(2)
else:
	print(3)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
MAXN = int(10000000.0 + 1)
spf = [0 for i in range(MAXN)]

def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = 0
	while x != 1:
		k = spf[x]
		ret += 1
		while x % k == 0:
			x //= k
	return ret
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def countPairs(G, L):
	if L % G != 0:
		return 0
	div = int(L / G)
	return 1 << getFactorization(div)

def main():
	a = []
	b = []
	for i in range(3):
		a.append(list(map(int, input().split())))
	if a[0][0] == a[1][0] == a[2][0] or a[0][1] == a[1][1] == a[2][1]:
		print(1)
	else:
		f = 0
		for i in range(3):
			for j in range(3):
				k = 3 - i - j
				if i != j:
					for t in range(2):
						if a[i][t] == a[j][t] and (a[k][1 ^ t] <= min(a[i][1 ^ t], a[j][1 ^ t]) or a[k][1 ^ t] >= max(a[i][1 ^ t], a[j][1 ^ t])):
							f = 1
		if f:
			print(2)
		else:
			print(3)
	return
main()


def main():
	temp1 = input().split()
	point1 = [int(x) for x in temp1]
	temp2 = input().split()
	point2 = [int(x) for x in temp2]
	temp3 = input().split()
	point3 = [int(x) for x in temp3]
	print(solver(point1, point2, point3))

def solver(point1, point2, point3):
	if sameX(point1, point2) and sameX(point2, point3):
		return 1
	elif sameY(point1, point2) and sameY(point2, point3):
		return 1
	if has2Segment(point1, point2, point3):
		return 2
	elif has2Segment(point1, point3, point2):
		return 2
	elif has2Segment(point2, point3, point1):
		return 2
	else:
		return 3

def has2Segment(point1, point2, point3):
	if sameX(point1, point2):
		top = max(point1[1], point2[1])
		bottom = min(point1[1], point2[1])
		if point3[1] >= top or point3[1] <= bottom:
			return True
		else:
			return False
	elif sameY(point1, point2):
		right = max(point1[0], point2[0])
		left = min(point1[0], point2[0])
		if point3[0] >= right or point3[0] <= left:
			return True
		else:
			return False
	else:
		return False

def sameX(point1, point2):
	return point1[0] == point2[0]

def sameY(point1, point2):
	return point1[1] == point2[1]
main()


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

def between(a, b, c):
	result = False
	if c > a and c < b or (c > b and c < a):
		result = True
	return result

def equals(a):
	result = 1
	ax = sorted(a, key=lambda x: x[0])
	if ax[0][0] == ax[1][0] and (not between(ax[0][1], ax[1][1], ax[2][1])) or (ax[1][0] == ax[2][0] and (not between(ax[1][1], ax[2][1], ax[0][1]))):
		result = 2
	elif ax[0][1] == ax[1][1] and (not between(ax[0][0], ax[1][0], ax[2][0])) or (ax[1][1] == ax[2][1] and (not between(ax[1][0], ax[2][0], ax[0][0]))):
		result = 2
	return result
if x1 == x2 and x2 == x3 or (y1 == y2 and y2 == y3):
	r = 3
else:
	r = equals([(x1, y1), (x2, y2), (x3, y3)])
print(3 - r + 1)


def f(a, b, c):
	return x[a] == x[b] and (y[c] <= min(y[a], y[b]) or y[c] >= max(y[a], y[b])) or (y[a] == y[b] and (x[c] <= min(x[a], x[b]) or x[c] >= max(x[a], x[b])))
(x, y) = list(zip(*[list(map(int, input().split(' '))) for i in range(3)]))
if len(set(x)) == 1 or len(set(y)) == 1:
	print(1)
elif f(0, 1, 2) or f(0, 2, 1) or f(1, 0, 2) or f(2, 1, 0) or f(2, 0, 1) or f(1, 2, 0):
	print(2)
else:
	print(3)


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)


def f(a, b, c):
	if a > min(b, c) and a < max(c, b):
		return True
(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = map(int, input().split())
if x1 == x2 and x2 == x3 or (y1 == y2 and y2 == y3):
	print(1)
elif x1 == x2 or x2 == x3 or x1 == x3 or (y1 == y2) or (y1 == y3) or (y2 == y3):
	if x1 == x2 and f(y3, y1, y2):
		print(3)
	elif x2 == x3 and f(y1, y2, y3):
		print(3)
	elif x1 == x3 and f(y2, y1, y3):
		print(3)
	elif y1 == y2 and f(x3, x1, x2):
		print(3)
	elif y2 == y3 and f(x1, x2, x3):
		print(3)
	elif y1 == y3 and f(x2, x3, x1):
		print(3)
	else:
		print(2)
else:
	print(3)


(x1, y1) = input().split()
(x2, y2) = input().split()
(x3, y3) = input().split()
x1 = int(x1)
x2 = int(x2)
x3 = int(x3)
y1 = int(y1)
y2 = int(y2)
y3 = int(y3)
ans = 3
if x1 == x2 and (y3 >= max(y1, y2) or y3 <= min(y1, y2)):
	ans = 2
if x1 == x3 and (y2 >= max(y1, y3) or y2 <= min(y1, y3)):
	ans = 2
if x2 == x3 and (y1 >= max(y2, y3) or y1 <= min(y2, y3)):
	ans = 2
if y1 == y2 and (x3 >= max(x1, x2) or x3 <= min(x1, x2)):
	ans = 2
if y1 == y3 and (x2 >= max(x1, x3) or x2 <= min(x1, x3)):
	ans = 2
if y2 == y3 and (x1 >= max(x2, x3) or x1 <= min(x2, x3)):
	ans = 2
if x1 == x2 and x2 == x3:
	ans = 1
if y1 == y2 and y2 == y3:
	ans = 1
print(ans)


(x1, y1) = list(map(lambda x: int(x), input().split()))
(x2, y2) = list(map(lambda x: int(x), input().split()))
(x3, y3) = list(map(lambda x: int(x), input().split()))

def how_many():
	if x1 == x2 and x2 == x3:
		return 1
	if y1 == y2 and y2 == y3:
		return 1
	if (x1 == x2 or x2 == x3 or x1 == x3) and (y1 == y2 or y2 == y3 or y1 == y3):
		return 2
	pos = [[x1, y1], [x2, y2], [x3, y3]]
	pos = sorted(pos, key=lambda x: x[0])
	if pos[0][1] == pos[1][1] or pos[1][1] == pos[2][1]:
		return 2
	pos = sorted(pos, key=lambda x: x[1])
	if pos[0][0] == pos[1][0] or pos[1][0] == pos[2][0]:
		return 2
	return 3
print(how_many())


x = []
y = []
for i in range(3):
	(x0, y0) = map(int, input().split(' '))
	x.append(x0)
	y.append(y0)
if all((x[0] == x0 for x0 in x)) or all((y[0] == y0 for y0 in y)):
	print(1)
	exit()
for i in range(3):
	for j in range(3):
		if i == j:
			continue
		k = 3 - i - j
		if x[i] == x[k] and min(y[i], y[j]) <= y[k] <= max(y[i], y[j]) or (y[i] == y[k] and min(x[i], x[j]) <= x[k] <= max(x[i], x[j])):
			print(2)
			exit()
print(3)


from sys import stdin
(a, b, c, d, e, f) = map(int, stdin.read().split())
res = [3]
for _ in (0, 1):
	if a == c == e:
		res.append(1)
	for _ in range(3):
		if a == c and (not (b < f < d or b > f > d)):
			res.append(2)
		(a, b, c, d, e, f) = (c, d, e, f, a, b)
	(a, b, c, d, e, f) = (b, a, d, c, f, e)
print(min(res))


(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)


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 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)
	elif 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()


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

def is_between(a, b, c):
	return min(a, b) <= c and c <= max(a, b)

def f(i, j, k):
	return (x[k] == x[i] or x[k] == x[j]) and is_between(y[i], y[j], y[k]) or ((y[k] == y[i] or y[k] == y[j]) and is_between(x[i], x[j], x[k]))
if x[1] == x[2] and x[2] == x[0] or (y[1] == y[2] and y[2] == y[0]):
	print('1')
elif f(0, 1, 2) or f(0, 2, 1) or f(1, 2, 0):
	print('2')
else:
	print('3')


g = lambda a, b, c, k: a[1 - k] == b[1 - k] and (not min(a[k], b[k]) < c[k] < max(a[k], b[k]))
f = lambda : list(map(int, input().split()))
t = [f(), f(), f()]
x = any((i == j == k for (i, j, k) in zip(*t)))
y = any((g(t[(s + 1) % 3], t[(s - 1) % 3], t[s], k) for s in [0, 1, 2] for k in [0, 1]))
print(3 - x - (x or y))


def good(one, two, three):
	if (one[0] == three[0] or two[0] == three[0]) and (min(one[1], two[1]) <= three[1] and three[1] <= max(one[1], two[1])):
		return True
	if (one[1] == three[1] or two[1] == three[1]) and (min(one[0], two[0]) <= three[0] and three[0] <= max(one[0], two[0])):
		return True

def f(a):
	a = sorted(a)
	if a[0][0] == a[1][0] == a[2][0] or a[0][1] == a[1][1] == a[2][1]:
		return 1
	if good(a[0], a[1], a[2]) or good(a[1], a[2], a[0]) or good(a[2], a[0], a[1]):
		return 2
	return 3
a = []
for i in range(3):
	(x, y) = map(int, input().strip().split())
	a.append((x, y))
print(f(a))


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)
	exit(0)
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)


a = []
for i in range(3):
	a.append(list(map(int, input().split())))
if a[0][0] == a[1][0] == a[2][0] or a[0][1] == a[1][1] == a[2][1]:
	print(1)
else:
	f = 0
	for i in range(3):
		for j in range(3):
			k = 3 - i - j
			if i != j:
				for t in range(2):
					if a[i][t] == a[j][t] and (a[k][1 ^ t] <= min(a[i][1 ^ t], a[j][1 ^ t]) or a[k][1 ^ t] >= max(a[i][1 ^ t], a[j][1 ^ t])):
						f = 1
	if f:
		print(2)
	else:
		print(3)


R = lambda : map(int, input().split())
(px, py) = ([], [])
for _ in range(3):
	(x, y) = R()
	px.append((x, y))
	py.append((y, x))
px = sorted(px)
py = sorted(py)

def solve(p):
	if p[0][0] == p[2][0]:
		return 1
	if p[0][0] == p[1][0] and (p[2][1] <= p[0][1] or p[2][1] >= p[1][1]):
		return 2
	if p[1][0] == p[2][0] and (p[0][1] <= p[1][1] or p[0][1] >= p[2][1]):
		return 2
	return 3
print(min(solve(px), solve(py)))


(x, y) = map(int, input().split())
(c, v) = map(int, input().split())
(b, n) = map(int, input().split())
if x == c and c == b or (y == v and v == n):
	print(1)
	exit()
ans = 3
if x == c and (n >= max(y, v) or n <= min(y, v)):
	ans = 2
elif x == b and (v >= max(y, n) or v <= min(y, n)):
	ans = 2
elif c == b and (y >= max(v, n) or y <= min(v, n)):
	ans = 2
elif y == v and (b >= max(x, c) or b <= min(x, c)):
	ans = 2
elif y == n and (c >= max(x, b) or c <= min(x, b)):
	ans = 2
elif v == n and (x >= max(c, b) or x <= min(c, b)):
	ans = 2
print(ans)


from collections import namedtuple
from itertools import permutations
Point = namedtuple('Point', 'x, y')

def get_ans(a, b, c):
	cnt = 1000
	for (a, b, c) in permutations((a, b, c)):
		if not (a.y <= b.y <= c.y or c.y <= b.y <= a.y):
			continue
		p = []
		p.append(Point(a.x, a.y))
		p.append(Point(b.x, a.y))
		p.append(Point(b.x, c.y))
		p.append(Point(c.x, c.y))
		cur = 0
		if p[1] != p[0]:
			cur += 1
		if p[2] != p[1]:
			cur += 1
		if p[3] != p[2]:
			cur += 1
		if cur < cnt:
			cnt = cur
	return cnt
(x, y) = map(int, input().split())
a = Point(x, y)
(x, y) = map(int, input().split())
b = Point(x, y)
(x, y) = map(int, input().split())
c = Point(x, y)
res = get_ans(a, b, c)
d = Point(a.y, a.x)
e = Point(b.y, b.x)
f = Point(c.y, c.x)
res = min(res, get_ans(d, e, f))
print(res)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 3
arr = [a, b, c]
arr.sort()
if a[0] == b[0] and b[0] == c[0] or (a[1] == b[1] and b[1] == c[1]):
	ans = 1
elif arr[0][0] == arr[1][0]:
	if abs(arr[0][1] - arr[1][1]) != abs(arr[0][1] - arr[2][1]) + abs(arr[1][1] - arr[2][1]) or (arr[2][1] == arr[0][1] or arr[2][1] == arr[1][1]):
		ans = 2
elif arr[1][0] == arr[2][0]:
	if abs(arr[1][1] - arr[2][1]) != abs(arr[1][1] - arr[0][1]) + abs(arr[2][1] - arr[0][1]) or (arr[0][1] == arr[1][1] or arr[0][1] == arr[2][1]):
		ans = 2
elif arr[0][1] == arr[1][1]:
	if abs(arr[0][0] - arr[1][0]) != abs(arr[0][0] - arr[2][0]) + abs(arr[1][0] - arr[2][0]) or (arr[2][0] == arr[0][0] or arr[2][0] == arr[1][0]):
		ans = 2
elif arr[0][1] == arr[2][1]:
	if abs(arr[0][0] - arr[2][0]) != abs(arr[0][0] - arr[1][0]) + abs(arr[2][0] - arr[1][0]) or (arr[1][0] == arr[0][0] or arr[1][0] == arr[2][0]):
		ans = 2
elif arr[1][1] == arr[2][1]:
	if abs(arr[1][0] - arr[2][0]) != abs(arr[1][0] - arr[0][0]) + abs(arr[2][0] - arr[0][0]) or (arr[0][0] == arr[1][0] or arr[0][0] == arr[2][0]):
		ans = 2
print(ans)


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)


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)


from math import ceil, log, floor, sqrt
import math

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_k(x, y, n):
	return (n - y) // x * x + y

def count_sticks(n):
	if n % 2 == 0:
		return n // 2
	return n // 2 + 1

def get_types(n, r):
	if r < n:
		return r * (r + 1) // 2
	r = n - 1
	return r * (r + 1) // 2 + 1

def happy_guests(a, b, n, m):
	mn = min(n, m)
	a -= mn
	b -= mn
	n -= mn
	m -= mn
	if a < 0 or b < 0:
		return False
	if n > 0:
		return a + b >= n
	return min(a, b) >= m

def find_max_len(s):
	n = len(s)
	(l, r) = (0, n - 1)
	count = n
	while l < r and s[l] == 'a':
		l += 1
	while r > l and s[r] == 'a':
		r -= 1
	for i in range(l, r + 1):
		if s[i] != 'b':
			count -= 1
	return count

def is_rectangle(a, b, c):
	for i in range(2):
		if a[i] == b[i]:
			idx = (i + 1) % 2
			if c[idx] >= max(a[idx], b[idx]) or c[idx] <= min(a[idx], b[idx]):
				return True
		if b[i] == c[i]:
			idx = (i + 1) % 2
			if a[idx] >= max(b[idx], c[idx]) or a[idx] <= min(b[idx], c[idx]):
				return True
		if a[i] == c[i]:
			idx = (i + 1) % 2
			if b[idx] >= max(a[idx], c[idx]) or b[idx] <= min(a[idx], c[idx]):
				return True
	return False

def count_lines(points):
	(mpx, mpy) = ({}, {})
	for point in points:
		if point[0] not in mpx:
			mpx[point[0]] = 1
		else:
			mpx[point[0]] += 1
		if point[1] not in mpy:
			mpy[point[1]] = 1
		else:
			mpy[point[1]] += 1
	if len(mpx) == 1 or len(mpy) == 1:
		return 1
	if is_rectangle(points[0], points[1], points[2]):
		return 2
	if is_rectangle(points[0], points[2], points[1]):
		return 2
	if is_rectangle(points[2], points[1], points[0]):
		return 2
	return 3
t = 1
while t:
	t = t - 1
	points = []
	for i in range(3):
		(x, y) = map(int, input().split())
		points.append((x, y))
	print(count_lines(points))


(a, b) = map(int, input().split())
(c, d) = map(int, input().split())
(e, f) = map(int, input().split())
if a == c == e or b == d == f:
	print(1)
elif (a == c or c == e or a == e) or (b == d or d == f or f == b):
	three = True
	if a == c:
		lis = sorted([b, d])
		if f <= lis[0] or f >= lis[1]:
			three = False
	if c == e:
		lis = sorted([d, f])
		if b <= lis[0] or b >= lis[1]:
			three = False
	if a == e:
		lis = sorted([b, f])
		if d <= lis[0] or d >= lis[1]:
			three = False
	if b == d:
		lis = sorted([a, c])
		if e <= lis[0] or e >= lis[1]:
			three = False
	if d == f:
		lis = sorted([c, e])
		if a <= lis[0] or a >= lis[1]:
			three = False
	if f == b:
		lis = sorted([a, e])
		if c <= lis[0] or c >= lis[1]:
			three = False
	if three:
		print(3)
	else:
		print(2)
else:
	print(3)


(a1, b1) = map(int, input().split())
(a2, b2) = map(int, input().split())
(a3, b3) = map(int, input().split())
if a1 == a2 and a2 == a3 or (b1 == b2 and b2 == b3):
	print(1)
elif a1 == a2:
	if b3 <= b1 and b3 <= b2 or (b3 >= b1 and b3 >= b2):
		print(2)
	else:
		print(3)
elif a1 == a3:
	if b2 <= b1 and b2 <= b3 or (b2 >= b1 and b2 >= b3):
		print(2)
	else:
		print(3)
elif a2 == a3:
	if b1 <= b3 and b1 <= b2 or (b1 >= b3 and b1 >= b2):
		print(2)
	else:
		print(3)
elif b1 == b2:
	if a3 <= a1 and a3 <= a2 or (a3 >= a1 and a3 >= a2):
		print(2)
	else:
		print(3)
elif b1 == b3:
	if a2 <= a1 and a2 <= a3 or (a2 >= a1 and a2 >= a3):
		print(2)
	else:
		print(3)
elif b2 == b3:
	if a1 <= a3 and a1 <= a2 or (a1 >= a3 and a1 >= a2):
		print(2)
	else:
		print(3)
else:
	print(3)


read = lambda : map(int, input().split())
bet = lambda a, b, c: a <= c <= b or b <= c <= a
f = lambda A, B, C: (C[0] == A[0] or C[0] == B[0]) and bet(A[1], B[1], C[1]) or ((C[1] == A[1] or C[1] == B[1]) and bet(A[0], B[0], C[0]))
(A, B, C) = (tuple(read()), tuple(read()), tuple(read()))
ans = 3
if f(A, B, C) or f(A, C, B) or f(B, C, A):
	ans = 2
if A[0] == B[0] == C[0] or A[1] == B[1] == C[1]:
	ans = 1
print(ans)


(a, b) = map(int, input().split())
(c, d) = map(int, input().split())
(e, f) = map(int, input().split())
if a == e == c or b == d == f:
	print(1)
else:
	ls = [(a, b), (c, d), (e, f)]
	ls.sort()
	if ls[0][0] == ls[1][0] and (ls[2][1] >= max(ls[0][1], ls[1][1]) or ls[2][1] <= min(ls[0][1], ls[1][1])) or (ls[1][0] == ls[2][0] and (ls[0][1] >= max(ls[1][1], ls[2][1]) or ls[0][1] <= min(ls[1][1], ls[2][1]))):
		print(2)
	else:
		ls.sort(key=lambda x: x[1])
		if ls[0][1] == ls[1][1] and (ls[2][0] >= max(ls[1][0], ls[0][0]) or ls[2][0] <= min(ls[0][0], ls[1][0])) or (ls[1][1] == ls[2][1] and (ls[0][0] >= max(ls[1][0], ls[2][0]) or ls[0][0] <= min(ls[1][0], ls[2][0]))):
			print(2)
		else:
			print(3)


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

def getCnt(a):
	if a[0] == a[1] == a[2]:
		return 3
	if a[0] == a[1] or a[0] == a[2] or a[1] == a[2]:
		return 2
	return 1
similar = max(getCnt(x), getCnt(y))
if similar == 3:
	print(1)
elif similar == 2:
	if getCnt(x) == 2:
		if x[0] == x[1]:
			(a, b, c) = (0, 1, 2)
		elif x[1] == x[2]:
			(a, b, c) = (1, 2, 0)
		else:
			(a, b, c) = (2, 0, 1)
		if y[c] > y[a] and y[c] < y[b] or (y[c] > y[b] and y[c] < y[a]):
			print(3)
		else:
			print(2)
	else:
		if y[0] == y[1]:
			(a, b, c) = (0, 1, 2)
		elif y[1] == y[2]:
			(a, b, c) = (1, 2, 0)
		else:
			(a, b, c) = (2, 0, 1)
		if x[c] > x[a] and x[c] < x[b] or (x[c] > x[b] and x[c] < x[a]):
			print(3)
		else:
			print(2)
else:
	print(3)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = map(int, input().split())
v1 = len(set([x1, x2, x3]))
v2 = len(set([y1, y2, y3]))
if v1 > v2:
	(v1, v2) = (v2, v1)
if v1 == 1:
	if v2 == 1:
		print(0)
	else:
		print(1)
elif v1 == 2:
	if v2 == 2:
		print(2)
	else:
		u1 = len(set([x1, x2, x3]))
		u2 = len(set([y1, y2, y3]))
		if u2 == 2:
			(x1, y1) = (y1, x1)
			(x2, y2) = (y2, x2)
			(x3, y3) = (y3, x3)
		if x2 == x3:
			(x3, x1) = (x1, x3)
			(y3, y1) = (y1, y3)
		elif x1 == x3:
			(x3, x2) = (x2, x3)
			(y3, y2) = (y2, y3)
		if y3 >= y1 and y3 <= y2 or (y3 >= y2 and y3 <= y1):
			print(3)
		else:
			print(2)
else:
	print(3)


def min_polyline(p1, p2, p3):
	if p1[0] != p2[0] and p1[1] != p2[1]:
		if p1[0] == p3[0] or p1[1] == p3[1]:
			(p2, p3) = (p3, p2)
		elif p2[0] == p3[0] or p2[1] == p3[1]:
			(p1, p3) = (p3, p1)
		else:
			return 3
	if p1[0] == p2[0]:
		if p3[0] == p1[0]:
			return 1
		elif p3[1] <= min(p1[1], p2[1]) or p3[1] >= max(p1[1], p2[1]):
			return 2
		else:
			return 3
	elif p3[1] == p1[1]:
		return 1
	elif p3[0] <= min(p1[0], p2[0]) or p3[0] >= max(p1[0], p2[0]):
		return 2
	else:
		return 3
print(min_polyline(*(tuple(map(int, input().split())) for _ in range(3))))


def isgood(a, b, c, d, e, f):
	global r
	if a == c or b == d:
		if (e > a and e < c or (e > c and e < a)) or (f > b and f < d or (f > d and f < b)):
			r = 1
		return True
	return False
(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
(x3, y3) = map(int, input().split())
c = 0
r = 0
if isgood(x1, y1, x2, y2, x3, y3):
	c += 1
if isgood(x1, y1, x3, y3, x2, y2):
	c += 1
if isgood(x3, y3, x2, y2, x1, y1):
	c += 1
if c == 0:
	print(3)
elif c == 3:
	print(1)
elif c == 2:
	print(2)
elif c == 1 and r == 1:
	print(3)
else:
	print(2)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def fn(x, y, a, b, c, d):
	if x == a and (not min(y, b) < d < max(y, b)) or (x == c and (not min(y, d) < b < max(y, d))):
		return True
	if y == b and (not min(x, a) < c < max(x, a)) or (y == d and (not min(x, c) < a < max(x, c))):
		return True
	return False
for _ in range(1):
	(x1, y1) = lst()
	(x2, y2) = lst()
	(x3, y3) = lst()
	ans = fn(x1, y1, x2, y2, x3, y3) or fn(x2, y2, x3, y3, x1, y1) or fn(x3, y3, x1, y1, x2, y2)
	if x1 == x2 == x3 or y1 == y2 == y3:
		print(1)
	elif ans:
		print(2)
	else:
		print(3)


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)


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)
elif yb == yc or (xb == xc and yc <= ya):
	print(2)
else:
	print(3)


def fun(x, y, z):
	(a, b, c, d, e, f) = aa[x] + aa[y] + aa[z]
	return a == c and (not (b < f < d or d < f < b)) or (b == d and (not (a < e < c or c < e < a)))
inn = lambda : map(int, input().split())
aa = [list(inn()), list(inn()), list(inn())]
if aa[0][0] == aa[1][0] == aa[2][0] or aa[0][1] == aa[1][1] == aa[2][1]:
	print(1)
elif fun(0, 1, 2) or fun(1, 2, 0) or fun(0, 2, 1):
	print(2)
else:
	print(3)