N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [0] * N
    max_index = -1
    max_surplus = 0
    surplus[0] = hp[0] * (2 ** A) - dmg[0]
    if max_surplus < surplus[0]:
        max_surplus = surplus[0]
        max_index = 0
    for i in range(1, N):
        surplus[i] = hp[i] * (2 ** A) - dmg[i]
        if max_surplus < surplus[i]:
            max_surplus = surplus[i]
            max_index = i

    print(sum(dmg) + max_surplus)
    quit()

# surplus = [0] * N
surplus = [hp[i] * (2 ** A) - dmg[i] for i in range(N)]
# max_index = -1
# max_surplus = 0

# surplus[0] = hp[0] * (2 ** A) - dmg[0]
# if max_surplus < surplus[0]:
#     max_surplus = surplus[0]
#     max_index = 0
# for i in range(1, N):
#     surplus[i] = hp[i] * (2 ** A) - dmg[i]
#     if max_surplus < surplus[i]:
#         max_surplus = surplus[i]
#         max_index = i

max_surplus = max(surplus)
max_index = surplus.index(max_surplus)

if max_surplus > 0:
    sur = [[i, 0] for i in range(N)]
    for i in range(N):
        if i != max_index:
            sur[i][1] = max(0, hp[i] - dmg[i])
        else:
            sur[i][1] = max_surplus

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)

else:
    sur = [[i, 0] for i in range(N)]
    for i in range(N):
        sur[i][1] = max(0, hp[i] - dmg[i])

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)


N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [0] * N
    max_index = -1
    max_surplus = 0
    surplus[0] = hp[0] * (2 ** A) - dmg[0]
    if max_surplus < surplus[0]:
        max_surplus = surplus[0]
        max_index = 0
    for i in range(1, N):
        surplus[i] = hp[i] * (2 ** A) - dmg[i]
        if max_surplus < surplus[i]:
            max_surplus = surplus[i]
            max_index = i

    print(sum(dmg) + max_surplus)
    quit()

# surplus = [0] * N
surplus = [hp[i] * (2 ** A) - dmg[i] for i in range(N)]
# max_index = -1
# max_surplus = 0

# surplus[0] = hp[0] * (2 ** A) - dmg[0]
# if max_surplus < surplus[0]:
#     max_surplus = surplus[0]
#     max_index = 0
# for i in range(1, N):
#     surplus[i] = hp[i] * (2 ** A) - dmg[i]
#     if max_surplus < surplus[i]:
#         max_surplus = surplus[i]
#         max_index = i

max_surplus = max(surplus)
max_index = surplus.index(max_surplus)

if max_surplus > 0:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]
    sur[max_index][1] = max_surplus

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)

else:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)


N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [hp[i] * (2 ** A) - dmg[i] for i in range(N)]
    max_surplus = max(surplus)

    print(sum(dmg) + max(0, max_surplus))
    quit()

surplus = [hp[i] << A - dmg[i] for i in range(N)]

max_surplus = max(surplus)
max_index = surplus.index(max_surplus)

if max_surplus > 0:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]
    sur[max_index][1] = max_surplus

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)

else:
    sur = [[i, max(0, hp[i] - dmg[i])] for i in range(N)]

    sur.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    for i in range(N):
        if B > 0:
            ans += dmg[sur[i][0]] + sur[i][1]
            B -= 1
        else:
            ans += dmg[sur[i][0]]

    print(ans)


N, A, B = map(int, input().split())
hp = []
dmg = []
for _ in range(N):
    h, d = map(int, input().split())
    hp.append(h)
    dmg.append(d)

if B == 0:
    print(sum(dmg))
    quit()
if B == 1:
    surplus = [0] * N
    max_index = -1
    max_surplus = 0
    surplus[0] = hp[0] * (2 ** A) - dmg[0]
    if max_surplus < surplus[0]:
        max_surplus = surplus[0]
        max_index = 0
    for i in range(1, N):
        surplus[i] = hp[i] * (2 ** A) - dmg[i]
        if max_surplus < surplus[i]:
            max_surplus = surplus[i]
            max_index = i

    print(sum(dmg) + max_surplus)
    quit()

surplus = [0] * N
max_index = -1
max_surplus = 0
surplus[0] = hp[0] * (2 ** A) - dmg[0]
if max_surplus < surplus[0]:
    max_surplus = surplus[0]
    max_index = 0
for i in range(1, N):
    surplus[i] = hp[i] * (2 ** A) - dmg[i]
    if max_surplus < surplus[i]:
        max_surplus = surplus[i]
        max_index = i

sur = [[i, 0] for i in range(N)]
for i in range(N):
    if i != max_index:
        sur[i][1] = max(0, hp[i] - dmg[i])
    else:
        sur[i][1] = max_surplus

sur.sort(key=lambda x: x[1], reverse=True)
ans = 0
for i in range(N):
    if B > 0:
        ans += dmg[sur[i][0]] + sur[i][1]
        B -= 1
    else:
        ans += dmg[sur[i][0]]

print(ans)


def well_played():
    n,a,b = [int(x) for x in input().split()]
    p = [(0,0)] * n
    b= min(b,n)

    for i in range(n):
        h,d =[int(x) for x in input().split()]
        p[i] =(h,d)
    p.sort(key=lambda x:x[0]-x[1],reverse=True)

    s=0
    for i in range(b):
        s+=max(p[i][0],p[i][1])
    for i in range(b,n):
        s+= p[i][1]

    ans = s
    for i in range(b):
        ans = max(ans,s - max(p[i][0],p[i][1]) + ((p[i][0]) <<a)  )
    s=s - max(p[b-1][0],p[b-1][1]) + p[b-1][1]
    if(b):
        for i in range(b,n):
            ans= max(ans,s - p[i][1] + ((p[i][0]) <<a) )
    print(ans)
well_played()


def well_played():
    n,a,b = [int(x) for x in input().split()]
    p = [(0,0)] * n
    b= min(b,n)

    for i in range(n):
        h,d =[int(x) for x in input().split()]
        p[i] =(h,d)
    p.sort(key=lambda x:x[0]-x[1],reverse=True)

    s=0
    for i in range(b):
        s+=max(p[i][0],p[i][1])
    for i in range(b,n):
        s+= p[i][1]

    ans = s
    for i in range(b):
        ans = max(ans,s - max(p[i][0],p[i][1]) + ((p[i][0]) <<a)  )
    s-= max(p[b-1][0],p[b-1][1]) + p[b-1][1]
    if(b):
        for i in range(b,n):
            ans= max(ans,s - p[i][1] + ((p[i][0]) <<a) )
    print(ans)
well_played()


from sys import stdin
rd = lambda l: list(map(int, l.split()))
n, a, b = rd(input())
b = min(b, n)
p = list(map(rd, stdin.readlines()))
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
s = sum(x[1] for x in p)
e = 0
if b:
    p.sort(key=f, reverse=True)
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
print(s + e)


rd = lambda: list(map(int, input().split()))
n, a, b = rd()
b = min(b, n)
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
p = [rd() for i in range(n)]
s = sum(x[1] for x in p)
e = 0
if b:
    p.sort(key=f, reverse=True)
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
print(s + e)


from sys import stdin
rd = lambda l: tuple(map(int, l.split()))
n, a, b = rd(input())
b = min(b, n)
p = list(map(rd, stdin.readlines()))
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
s = sum(x[1] for x in p)
e = 0
if b:
    p.sort(key=f, reverse=True)
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
    s += e
print(s)


from sys import stdin
rd = lambda l: tuple(map(int, l.split()))
n, a, b = rd(input())
b = min(b, n)
p = list(map(rd, stdin.readlines()))
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
s = sum(x[1] for x in p)
e = 0
if b:
    p.sort(key=f, reverse=True)
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
print(s + e)


from sys import stdin
rd = lambda l: tuple(map(int, l.split()))
n, a, b = rd(input())
b = min(b, n)
p = list(map(rd, stdin.readlines()))
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
s = sum(x[1] for x in p)
e = 0
if b:
    p.sort(key=f, reverse=True)
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
s += e
print(s)


import sys
if locals()['__file__'][-2:] == 'py':
    sys.stdin = open('in.txt', 'r')
# rd = lambda: map(int, input().split())
# n, a, b = rd()
# p = []
# b = min(b, n)
# s = 0
# ans = 0
# for i in range(n):
#     hp, dmg = rd()
#     p.append([max(hp - dmg, 0), hp, dmg])
#     s += dmg
# if b:
#     p.sort(reverse=True)
#     t = 0
#     for i in range(b):
#         t += p[i][0]
#     for i in range(b):
#         ans = max(ans, t - p[i][0] + (p[i][1] << a) - p[i][2])
#     for i in range(b, n):
#         ans = max(ans, t - p[b - 1][0] + (p[i][1] << a) - p[i][2])
# print(ans + s)

rd = lambda: list(map(int, input().split()))
n, a, b = rd()
b = min(b, n)
f = lambda x: max(0, x[0] - x[1])
g = lambda x: (x[0] << a) - x[1]
p = [rd() for i in range(n)]
s = sum(x[1] for x in p)
if b:
    p.sort(key=f, reverse=True)
    e = 0
    t = sum(f(x) for x in p[:b])
    for i in range(b):
        e = max(e, t - f(p[i]) + g(p[i]))
    for i in range(b, n):
        e = max(e, t - f(p[b - 1]) + g(p[i]))
print(s + e)

# python3
# from sys import stdin

# def main():
#     def parseints(line): return tuple(map(int, line.split()))
#     def bdiff(creature): return max(0, creature[0] - creature[1])

#     n, a, b = parseints(input())
#     hand = list(map(parseints, stdin.readlines()))

#     ans = sum(creature[1] for creature in hand)  # default damage
#     if b:
#         hand.sort(key=bdiff)

#         best = 0
#         if n > b:
#             lost = bdiff(hand[n - b])
#             for creature in hand[:n-b]:
#                 best = max(best, (creature[0] << a) - creature[1] - lost)

#         for creature in hand[max(0,n-b):]:
#             best = max(best, (creature[0] << a) - max(creature))
#             ans += bdiff(creature)
#         ans += best

#     print(ans)

# main()


# python3

def solve():
    def readline(): return tuple(map(int, input().split()))

    def bdiff(creature): return max(0, creature[0] - creature[1])

    n, a, b = readline()
    hand = [readline() for __ in range(n)]

    ans = sum(creature[1] for creature in hand)  # default damage
    if b:
        hand.sort(key=bdiff)

        best = 0
        if n > b:
            lost = bdiff(hand[n - b])
            for creature in hand[:n-b]:
                best = max(best, (creature[0] << a) - creature[1] - lost)

        for creature in hand[max(0,n-b):]:
            best = max(best, (creature[0] << a) - max(creature))
            ans += bdiff(creature)
        ans += best

    print(ans)

solve()


# python3
from sys import stdin
from collections import namedtuple

def readline(): return tuple(map(int, input().split()))

class Creature(namedtuple('Creature', 'hp dmg')):
    pass

n, a, b = readline()
hand = [Creature(*map(int, line.split())) for line in stdin.readlines()]

if not b:
    print(sum(creature.dmg for creature in hand))
else:
    hand.sort(key=lambda self: self.hp - self.dmg)

    best = 0
    if n > b:
        l = hand[n - b]
        lost = max(0, l.hp - l.dmg)
        for creature in hand[:n-b]:
            best = max(best, (creature.hp << a) - creature.dmg - lost)

    for creature in hand[max(0,n-b):]:
        best = max(best, (creature.hp << a) - max(creature.hp, creature.dmg))

    print(sum(creature.dmg for creature in hand)
          + sum(max(0, creature.hp - creature.dmg) for creature in hand[max(0,n-b):])
          + best)


# python3
def readline(): return tuple(map(int, input().split()))

def solve():
    def bdiff(creature): return max(0, creature[0] - creature[1])

    n, a, b = readline()
    hand = [readline() for __ in range(n)]

    ans = sum(creature[1] for creature in hand)  # default damage
    if b:
        hand.sort(key=bdiff)

        best = 0
        if n > b:
            lost = bdiff(hand[n - b])
            for creature in hand[:n-b]:
                best = max(best, (creature[0] << a) - creature[1] - lost)

        for creature in hand[max(0,n-b):]:
            best = max(best, (creature[0] << a) - max(creature))
            ans += bdiff(creature)
        ans += best

    print(ans)

solve()


# python3
from sys import stdin
from collections import namedtuple

def readline(): return tuple(map(int, input().split()))

class Creature(namedtuple('Creature', 'hp dmg')):
    def b(self): return max(0, self.hp - self.dmg)
    def bdmg(self): return max(self.hp, self.dmg)

def solve():
    n, a, b = readline()
    hand = [Creature(*map(int, line.split())) for line in stdin.readlines()]

    if not b: return sum(creature.dmg for creature in hand)

    hand.sort(key=Creature.b)

    best = 0
    if n > b:
        lost = hand[n - b].b()
        for creature in hand[:n-b]:
            best = max(best, (creature.hp << a) - creature.dmg - lost)

    for creature in hand[max(0,n-b):]:
        best = max(best, (creature.hp << a) - creature.bdmg())

    return sum(creature.dmg for creature in hand) \
           + sum(creature.b() for creature in hand[max(0,n-b):]) \
           + best

print(solve())


# python3

def solve():
    def readline(): return tuple(map(int, input().split()))

    def bdiff(creature): return max(0, creature[0] - creature[1])

    n, a, b = readline()
    hand = [readline() for __ in range(n)]

    ans = sum(creature[1] for creature in hand)  # default damage
    if b:
        hand.sort(key=bdiff)

        best = 0
        if n > b:
            lost = bdiff(hand[n - b])
            for creature in hand[:n-b]:
                best = max(best, (creature[0] << a) - creature[1] - lost)

        for creature in hand[max(0,n-b):]:
            best = max(best, (creature[0] << a) - max(creature))
            ans += max(0, creature[0] - creature[1])
        ans += best

    print(ans)

solve()


# python3
from sys import stdin
from collections import namedtuple

def readline(): return tuple(map(int, input().split()))

class Creature(namedtuple('Creature', 'hp dmg')):
    def b(self): return max(0, self.hp - self.dmg)

def solve():
    n, a, b = readline()
    hand = [Creature(*map(int, line.split())) for line in stdin.readlines()]

    if not b: return sum(creature.dmg for creature in hand)

    hand.sort(key=Creature.b)

    best = 0
    if n > b:
        lost = hand[n - b].b()
        for creature in hand[:n-b]:
            best = max(best, (creature.hp << a) - creature.dmg - lost)

    for creature in hand[max(0,n-b):]:
        best = max(best, (creature.hp << a) - max(creature.hp, creature.dmg))

    return sum(creature.dmg for creature in hand) \
           + sum(creature.b() for creature in hand[max(0,n-b):]) \
           + best

print(solve())


# python3
from sys import stdin

def readline(): return tuple(map(int, input().split()))

def bdiff(creature): return max(0, creature[0] - creature[1])

n, a, b = readline()
hand = [tuple(map(int, line.split())) for line in stdin.readlines()]

ans = sum(creature[1] for creature in hand)  # default damage
if b:
    hand.sort(key=bdiff)

    best = 0
    if n > b:
        lost = bdiff(hand[n - b])
        for creature in hand[:n-b]:
            best = max(best, (creature[0] << a) - creature[1] - lost)

    for creature in hand[max(0,n-b):]:
        best = max(best, (creature[0] << a) - max(creature))
        ans += bdiff(creature)
    ans += best

print(ans)


# python3
from collections import namedtuple

def readline(): return tuple(map(int, input().split()))

class Creature(namedtuple('Creature', 'hp dmg')):
    def b(self): return max(0, self.hp - self.dmg)
    def bdmg(self): return max(self.hp, self.dmg)

class Maximizator:
    def __init__(self, value): self.value = value
    def eat(self, value): self.value = max(self.value, value)

def solve():
    n, a, b = readline()
    hand = [Creature(*readline()) for __ in range(n)]

    if not b: return sum(creature.dmg for creature in hand)

    hand.sort(key=Creature.b)

    best = Maximizator(0)
    if n > b:
        lost = hand[n - b].b()
        for creature in hand[:n-b]:
            best.eat((creature.hp << a) - creature.dmg - lost)

    for creature in hand[max(0,n-b):]:
        best.eat((creature.hp << a) - creature.bdmg())

    return sum(creature.dmg for creature in hand) \
           + sum(creature.b() for creature in hand[max(0,n-b):]) \
           + best.value

print(solve())


# python3
from sys import stdin

def main():
    def parseints(line): return tuple(map(int, line.split()))
    def bdiff(creature): return max(0, creature[0] - creature[1])

    n, a, b = parseints(input())
    hand = list(map(parseints, stdin.readlines()))

    ans = sum(creature[1] for creature in hand)  # default damage
    if b:
        hand.sort(key=bdiff)

        best = 0
        if n > b:
            lost = bdiff(hand[n - b])
            for creature in hand[:n-b]:
                best = max(best, (creature[0] << a) - creature[1] - lost)

        for creature in hand[max(0,n-b):]:
            best = max(best, (creature[0] << a) - max(creature))
            ans += bdiff(creature)
        ans += best

    print(ans)

main()


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    printf("%d\n",(t-4)/2);
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n+1;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx > v[i].first) {
			if(miny > v[i].second) {
				ind = i,miny = v[i].second,minx = v[i].first;
			}
		}
	}

	int j = ind;
	for(int i=1;i <= n+1;i++) {
		p[i] = v[j++];
		if(j == n+2) j = 1;
	}

	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}
	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n+1;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx >= v[i].first) {
			if(miny > v[i].second) {
				ind = i,miny = v[i].second,minx = v[i].first;
			}
		}
	}

	int j = ind;
	for(int i=1;i <= n+1;i++) {
		p[i] = v[j++];
		if(j == n+2) j = 1;
	}

	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}

	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n+1;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx >= v[i].first) {
			minx = v[i].first;
		}
	}

	for(int i=1;i <= n+1;i++) {
		if(minx == v[i].first) {
			if(miny > v[i].second) {
				miny = v[i].second;
				ind = i;
			}
		}
	}
	int j = ind;
	//cout << ind << "\n";
	for(int i=1;i <= n+1;i++) {
		p[i] = v[j++];
		if(j == n+2) j = 1;
	}
	//cout << p[1].first << ' ' << p[1].second << "\n";
	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}

	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n+1;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx >= v[i].first) {
			if(miny >= v[i].second) {
				ind = i,miny = v[i].second,minx = v[i].first;
			}
		}
	}

	int j = ind;
	//cout << ind << "\n";
	for(int i=1;i <= n+1;i++) {
		p[i] = v[j++];
		if(j == n+2) j = 1;
	}
	//cout << p[1].first << ' ' << p[1].second << "\n";
	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}

	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans-1;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx >= v[i].first) {
			minx = v[i].first;
		}
	}
	int k,l;
	cin >> k >> l;
	for(int i=1;i <= n;i++) {
		if(minx == v[i].first) {
			if(miny > v[i].second) {
				miny = v[i].second;
				ind = i;
			}
		}
	}
	int j = ind;
	//cout << ind << "\n";
	for(int i=1;i <= n;i++) {
		p[i] = v[j++];
		//cout << p[i].first << ' ' << p[i].second << "\n";
		if(j == n+1) j = 1;
	}
	p[n+1] = p[1];
	//cout << p[1].first << ' ' << p[1].second << "\n";
	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}

	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x and y3 == y) continue;
		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	pair<int,int> v[n+11],p[n+11];

	int minx = 1000000000,miny = 1000000000,ind = 0;
	for(int i=1;i <= n+1;i++) {
		cin >> v[i].first >> v[i].second;
		if(minx >= v[i].first) {
			minx = v[i].first;
		}
	}

	for(int i=1;i <= n+1;i++) {
		if(minx == v[i].first) {
			if(miny > v[i].second) {
				miny = v[i].second;
				ind = i;
			}
		}
	}

	int j = ind;
	//cout << ind << "\n";
	for(int i=1;i <= n+1;i++) {
		p[i] = v[j++];
		//cout << p[i].first << ' ' << p[i].second << "\n";
		if(j == n+2) j = 1;
	}
	//cout << p[1].first << ' ' << p[1].second << "\n";
	int x1=p[1].first,y1=p[1].second,x2=p[2].first,y2=p[2].second,x3=p[3].first,y3=p[3].second;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}

	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		x = p[i].first,y = p[i].second;

		if(x3 == x and y3 == y) continue;
		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main() {
	// your code goes here

	int n;
	cin >> n;

	int x1,y1,x2,y2,x3,y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	int cross = 0,prev = 0;
	if(x3 > x2) {
		cross = -1;
		prev = 1;
	}
	else {
		cross = 1;
		prev = -1;
	}
	int ans = 0;
	for(int i=4;i <= n+1;i++) {
		int x,y;
		cin >> x >> y;

		if(x3 == x) {
			if(y3 > y) {
				if(prev == -1 and cross == -1) ans++;
				if(prev == 1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = 1;
			}
		}
		else {
			if(x3 > x) {
				if(prev == 1 and cross == -1) ans++;
				if(prev == -1 and cross == 1) ans++;
				prev = -1;
			}else {
				if(prev == 1 and cross == 1) ans++;
				if(prev == -1 and cross == -1) ans++;
				prev = 1;
			}
		}
		x3 = x,y3 = y;
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	cout<<(n-4)/2;
}


#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
int main(){
    cin>>n;
    cout<<(n-4)/2<<endl;
	return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	printf("%d",(n-4)/2);
	return 0;
}


#include<bits/stdc++.h>
int n;
int main()
{
	scanf("%d",&n),printf("%d",(n-4)/2),exit(0);
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<algorithm>

using namespace std;

int n;
double maxx, minx, maxy, miny;

struct node{
	int xx, yy;
};
node t[1010];

int main() {
	scanf("%d", &n);
	for (int i = 0; i <= n; i++) {
		scanf("%d %d", &t[i].xx, &t[i].yy);
	}
	int last = 1;
	int status = 0;
	int ans = 0;
/*	for (int i = 1; i < n; i++) {
		double ta = tan(i);

		last = ta;
	}*/
	printf("%d\n", n / 2 - 2);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int n,i,x[1010],y[1010],ans;

struct point{int x,y;}p[1010];

int multi(point a,point b){return a.x*b.y-b.x*a.y;}

int main(){

	scanf("%d%d%d",&n,&x[0],&y[0]);

	for(i=1;i<=n;i++) scanf("%d%d",x+i,y+i),p[i].x=x[i]-x[i-1],p[i].y=y[i]-y[i-1];

	p[0]=p[n];

	for(i=0;i<n;i++) if(multi(p[i],p[i+1])>0) ans++;

	printf("%d\n",ans);

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define inf 1e100

#define squ(a,b) (a)*(a)+(b)*(b)

#define pi 3.1415926535897932384626433832795

using namespace std;

typedef double DO;

typedef long long INT;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

//2-dimension point struct (double)

struct point {

	DO x, y;

	point (DO x=0, DO y=0) : x(x), y(y) {}

	point operator - (point a) {return point(x-a.x, y-a.y);}

	point operator + (point a) {return point(x+a.x, y+a.y);}

	point operator * (DO a) {return point(x*a, y*a);}

	point operator / (DO a) {return point(x/a, y/a);}

	point operator & (point a) {return point(x*a.x-y*a.y, x*a.y+y*a.x);}

	point rotate(DO al) {return *this&point(cos(al), sin(al));}

	DO    operator ^ (point a) {return x*a.y-y*a.x;}

	DO    operator * (point a) {return x*a.x+y*a.y;}

	point norm() {DO s=nor(); if (s<eps) return *this; return point(x/s, y/s);}

	point conj() {return point(-y, x);}

	DO nor() {return sqrt(*this**this);}

	DO al() {return atan2(y, x);}

	bool operator < (const point &a) const {

		if (fabs(x-a.x)>eps) return x<a.x;

		return y<a.y-eps;

	}

	bool operator > (const point &a) const {

		if (fabs(x-a.x)>eps) return x>a.x;

		return y>a.y+eps;

	}

	bool operator == (const point &a) const {

		if (fabs(x-a.x)>eps) return 0;

		return fabs(y-a.y)<eps;

	}

	bool operator != (const point &a) const {

		if(*this==a) return false;

		return true;

	}

	void input() {scanf("%lf %lf", &x, &y);}

	void print() {printf("%lf %lf\n", x, y);}

};

double dist(point a, point b){

	return sqrt(squ(a.x-b.x,a.y-b.y));

}

int sgn(DO a) {return (a>eps)-(a<-eps);}

bool is_on(point a, point b, point c) {

	if (sgn(a-b^b-c)) return 0;

	return sgn((a-c)*(b-c))<=0;

}

bool intersect(point a, point b, point c, point d, point &ans) {

	if (min(a.x, b.x)>max(c.x, d.x)+eps) return 0;

	if (max(a.x, b.x)<min(c.x, d.x)-eps) return 0;

	if (min(a.y, b.y)>max(c.y, d.y)+eps) return 0;

	if (max(a.y, b.y)<min(c.y, d.y)-eps) return 0;

	if (sgn((a-b)^(c-b))*sgn((a-b)^(d-b))>=0) return 0;

	if (sgn((c-d)^(a-d))*sgn((c-d)^(b-d))>=0) return 0;

	DO sc=fabs((a-b)^(b-c)), sd=fabs((a-b)^(b-d));

	ans=(c*sd+d*sc)/(sc+sd);

	return 1;

}

DO angle(point a, point b) {

	DO res=a*b/a.nor()/b.nor();

	res=acos(res);

	return res;

}

DO angle(point a, point b, point c) {

	return angle(a-c, b-c);

}

DO pdist(point c, point a, point b) {

	point aa=c-a, bb=c-b, ab=a-b;

	if(sgn(aa*ab)>=0) return aa.nor();

	if(sgn(bb*ab)<=0) return bb.nor();

	return fabs(aa^bb)/ab.nor();

}

bool is_in_poly(point a, point *p, int n) {

	for (int i=0; i<n; i++) if (is_on(p[i], p[i+1], a)) return 1;

	int cnt=0;

	for (int i=0; i<n; i++) {

		point b=p[i], c=p[i+1];

		if (b>c) swap(b, c);

		if (sgn(c-b^a-b)<0 && b.x<a.x-eps && a.x<c.x+eps) cnt++;

	}

	return cnt&1;

}

point a[10010];

int main(){

	#ifndef ONLINE_JUDGE

	freopen("in.in","r",stdin);

	freopen("out.out","w",stdout);

	#endif

	int n;cin>>n;int ans=0;

	for(int i=0; i<n; i++) a[i].input();

	a[n]=a[0];a[n+1]=a[1];

	for(int i=1; i<=n; i++){

		if((a[i-1]-a[i]^a[i+1]-a[i])<eps){

			ans++;

		}

	}

	printf("%d\n",ans);

}


#include<bits/stdc++.h>

#define x first

#define y second

#define eps 1e-8

#define inf 1e100

#define squ(a,b) (a)*(a)+(b)*(b)

#define pi 3.1415926535897932384626433832795

using namespace std;

typedef double DO;

typedef long long INT;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

//2-dimension point struct (double)

struct point {

	DO x, y;

	point (DO x=0, DO y=0) : x(x), y(y) {}

	point operator - (point a) {return point(x-a.x, y-a.y);}

	point operator + (point a) {return point(x+a.x, y+a.y);}

	point operator * (DO a) {return point(x*a, y*a);}

	point operator / (DO a) {return point(x/a, y/a);}

	point operator & (point a) {return point(x*a.x-y*a.y, x*a.y+y*a.x);}

	point rotate(DO al) {return *this&point(cos(al), sin(al));}

	DO    operator ^ (point a) {return x*a.y-y*a.x;}

	DO    operator * (point a) {return x*a.x+y*a.y;}

	point norm() {DO s=nor(); if (s<eps) return *this; return point(x/s, y/s);}

	point conj() {return point(-y, x);}

	DO nor() {return sqrt(*this**this);}

	DO al() {return atan2(y, x);}

	bool operator < (const point &a) const {

		if (fabs(x-a.x)>eps) return x<a.x;

		return y<a.y-eps;

	}

	bool operator > (const point &a) const {

		if (fabs(x-a.x)>eps) return x>a.x;

		return y>a.y+eps;

	}

	bool operator == (const point &a) const {

		if (fabs(x-a.x)>eps) return 0;

		return fabs(y-a.y)<eps;

	}

	bool operator != (const point &a) const {

		if(*this==a) return false;

		return true;

	}

	void input() {scanf("%lf %lf", &x, &y);}

	void print() {printf("%lf %lf\n", x, y);}

};

point a[10010];

int main(){

	#ifndef ONLINE_JUDGE

	freopen("in.in","r",stdin);

	freopen("out.out","w",stdout);

	#endif

	int n;cin>>n;int ans=0;

	for(int i=0; i<n; i++) a[i].input();

	a[n]=a[0];a[n+1]=a[1];

	for(int i=1; i<=n; i++){

		if((a[i-1]-a[i]^a[i+1]-a[i])<eps){

			ans++;

		}

	}

	printf("%d\n",ans);

}


//In the name of GOD

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define Oooops ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define S second
#define F first

typedef pair<int, string> pii;

const int maxn = 1e3 + 100;
int n;
int x[maxn];
int z[maxn];
int res;

main()
{
    cin >> n;
    for (int i = 0; i <= n; i++)
        cin >> x[i] >> z[i];

    for (int i = 1; i < n; i++)
    {
        if (x[i] == x[i-1])
        {
            if (z[i] > z[i-1])
            {
                if (x[i+1] < x[i])
                    res ++;
            }
            else
            {
                if (x[i+1] > x[i])
                    res ++;
            }
        }

        if (z[i] == z[i-1])
        {
            if (x[i] > x[i-1])
            {
                if (z[i+1] > z[i])
                    res ++;
            }

            else
            {
                if (z[i+1] < z[i])
                    res ++;
            }
        }
    }
    if (x[n] == x[n-1])
    {
        if (z[n] > z[n-1])
        {
            if (x[1] < x[n])
                res ++;
        }
        else
        {
            if (x[1] > x[n])
                res ++;
        }
    }

    if (z[n] == z[n-1])
    {
        if (x[n] > x[n-1])
        {
            if (z[1] > z[n])
                res ++;
        }

        else
        {
            if (z[1] < z[n])
                res ++;
        }
    }
    cout << res << endl;

    return 0;
}


//In the name of GOD

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define Oooops ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define S second
#define F first

typedef pair<int, string> pii;

const int maxn = 1e3 + 100;
int n;
int x[maxn];
int z[maxn];
int res;

main()
{
    cin >> n;
    for (int i = 0; i <= n; i++)
        cin >> x[i] >> z[i];

    for (int i = 1; i < n; i++)
    {
        if (x[i] == x[i-1])
        {
            if (z[i] > z[i-1])
            {
                if (x[i+1] < x[i])
                    res ++;
            }
            else
            {
                if (x[i+1] > x[i])
                    res ++;
            }
        }

        if (z[i] == z[i-1])
        {
            if (x[i] > x[i-1])
            {
                if (z[i+1] > z[i])
                    res ++;
            }

            else
            {
                if (z[i+1] < z[i])
                    res ++;
            }
        }
    }

    cout << res << endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

const int N = 1005;
const int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int n, x[N], y[N];

int get(int x1, int y1, int x2, int y2) {
    if (x1 == x2) {
        if (y2 > y1) return 0;
        return 2;
    }
    if (y1 == y2) {
        if (x2 > x1) return 1;
        return 3;
    }
}

bool judge(int a, int b) {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int x1 = x[i], y1 = y[i];
        int x2 = x[i + 1], y2 = y[i + 1];
        if (x1 == x2) {
            if (y1 > y2) swap(y1, y2);
            if (a == x1 && b >= y1 && b <= y2) return false;
            if (a < x1 && b > y1 && b <= y2)
                cnt++;
        }
        if (y1 == y2) {
            if (x1 > x2) swap(x1, x2);
            if (b == y1 && a >= x1 && a <= x2) return false;
        }
    }
    return cnt % 2;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++) {
        scanf("%d%d", &x[i], &y[i]);
        x[i] *= 2;
        y[i] *= 2;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int d = get(x[i], y[i], x[i + 1], y[i + 1]);
        if (judge(x[i + 1] + dir[d][0], y[i + 1] + dir[d][1])) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


#include <cstdio>

int n;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%*d%*d");
    printf("%d\n", (n - 4) / 2);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0) ;
    int n, maxX = -100000, minX = 100000, maxY = -100000, minY = 100000 ;
    cin >> n ;
    vector< pair<int, int> > points(n+1) ;
    int ans = 0 ;
    char curr = 'U' ;
    for(int i=0;i<n+1;i++)
        cin >> points[i].first >> points[i].second ;
    for(int i=1;i<n+1;i++)
    {
        if(curr=='U')
        {
            if(points[i+1].first<points[i].first)
            {
                curr = 'L' ;
                ans++ ;
            }else
                curr = 'R' ;
        }else if(curr=='R')
        {
            if(points[i+1].second>points[i].second)
            {
                curr = 'U' ;
                ans++ ;
            }else
                curr = 'D' ;
        }else if(curr=='D')
        {
            if(points[i+1].first<points[i].first)
                curr = 'L' ;
            else
            {
                curr = 'R' ;
                ans++ ;
            }
        }else
        {
            if(points[i+1].second<points[i].second)
            {
                curr = 'D' ;
                ans++ ;
            }else
                curr = 'U' ;
        }
    }
    cout << ans ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0) ;
    int n, maxX = -100000, minX = 100000, maxY = -100000, minY = 100000 ;
    cin >> n ;
    vector<pair<int, int>> points(n+1) ;
    int ans = 0 ;
    char curr = 'U' ;
    for(int i=0;i<n+1;i++)
        cin >> points[i].first >> points[i].second ;
    //cout << "\n\n" ;
    for(int i=1;i<n+1;i++)
    {
        /*cout << points[i].first << " " << points[i].second << endl ;
        cout << curr << " " << ans << endl ;*/
        if(curr=='U')
        {
            if(points[i+1].first<points[i].first)
            {
                curr = 'L' ;
                ans++ ;
            }else
                curr = 'R' ;
        }else if(curr=='R')
        {
            if(points[i+1].second>points[i].second)
            {
                curr = 'U' ;
                ans++ ;
            }else
                curr = 'D' ;
        }else if(curr=='D')
        {
            if(points[i+1].first<points[i].first)
                curr = 'L' ;
            else
            {
                curr = 'R' ;
                ans++ ;
            }
        }else
        {
            if(points[i+1].second<points[i].second)
            {
                curr = 'D' ;
                ans++ ;
            }else
                curr = 'U' ;
        }
    }
    //cout << endl ;
    cout << ans ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0) ;
    int n, maxX = -100000, minX = 100000, maxY = -100000, minY = 100000 ;
    cin >> n ;
    vector<pair<int, int>> points(n+1) ;
    int ans = 0 ;
    char curr = 'U' ;
    for(int i=0;i<n+1;i++)
        cin >> points[i].first >> points[i].second ;
    for(int i=1;i<n+1;i++)
    {
        if(curr=='U')
        {
            if(points[i+1].first<points[i].first)
            {
                curr = 'L' ;
                ans++ ;
            }else
                curr = 'R' ;
        }else if(curr=='R')
        {
            if(points[i+1].second>points[i].second)
            {
                curr = 'U' ;
                ans++ ;
            }else
                curr = 'D' ;
        }else if(curr=='D')
        {
            if(points[i+1].first<points[i].first)
                curr = 'L' ;
            else
            {
                curr = 'R' ;
                ans++ ;
            }
        }else
        {
            if(points[i+1].second<points[i].second)
            {
                curr = 'D' ;
                ans++ ;
            }else
                curr = 'U' ;
        }
    }
    cout << ans ;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, x[1010], y[1010];

int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
#endif
	scanf("%d", &n);
	for(int i=0 ; i<n ; ++i)
		scanf("%d%d", &x[i], &y[i]);
	int ans = 0;
	for(int prev, after, i=1 ; i<n ; ++i) {
		prev = ((i-1)%n + n ) %n;
		after = ((i+1)%n + n) % n;
		if(y[i] == y[prev]) {
			if((x[i] - x[prev]) * (y[after] - y[i]) > 0)
				++ans;
		} else if(x[i] == x[prev]) {
			if((y[i] - y[prev]) * (x[after] - x[i]) < 0)
				++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


#include<cstdio> using namespace std; int main() { int n; scanf("%d", &n); cout<<(n-4)/2<<endl; return 0;}


#include<cstdio>;
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	printf("%d", (n - 4) / 2);
	return 0;
}


#include<cstdio> using namespace std; int main() { int n; scanf("%d", &n); printf("%d", (n-4)/2); return 0;}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main (){
  int n,ans;
  int x[1055];
  int y[1055];
  while (~scanf("%d",&n)){
    for (int i=0;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
   ans=(n-4)/2;
  printf("%d\n",ans);
  }
return 0;

}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main (){
  int n,ans;
  int x[1055];
  int y[1055];
  while (~scanf("%d",&n)){
    for (int i=0;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
   ans=(n-4)/2;
  printf("%d\n",ans);
  }
return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main (){
  int n,ans;
  int x[1005];
  int y[1005];
  while (~scanf("%d",&n)){
    for (int i=0;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
ans=(n-4)/2;
  printf("%d\n",ans);
  }
return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main (){
  int n,ans;
  int x[1005];
  int y[1005];
  while (~scanf("%d",&n)){
    for (int i=0;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }

    ans=(n-4)/2;
  printf("%d\n",ans);
  }

return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main (){
  int n,ans;
  int x[1005];
  int y[1005];
  while (~scanf("%d",&n)){
    for (int i=0;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }

    ans=(n-4)/2;
  printf("%d\n",ans);
  }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MX 100005
#define MD 1000000007
typedef long long ll;
typedef pair<pair<int,int>,int> piii;

ll n, x[1005], y[1005], ans;

int main() {
    cin >> n;
    for(int i = 0; i <= n; i++) cin >> x[i] >> y[i];
    for(int i = 1; i < n; i++){
        if(y[i-1] < y[i] && x[i+1] < x[i]) ans++;
        else if(y[i+1] > y[i] && x[i-1] < x[i]) ans++;
        else if(y[i-1] > y[i] && x[i+1] > x[i]) ans++;
        else if(y[i+1] < y[i] && x[i-1] > x[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MX 100005
#define MD 1000000007
typedef long long ll;
typedef pair<pair<int,int>,int> piii;

ll n, x[1005], y[1005], ans;

int main() {
    cin >> n;
    for(int i = 0; i <= n; i++) cin >> x[i] >> y[i];
    for(int i = 1; i < n; i++){
        if(y[i-1] < y[i] && x[i+1] < x[i]) ans++;
        else if(y[i+1] > y[i] && x[i-1] < x[i]) ans++;
        else if(y[i-1] > y[i] && x[i+1] > x[i]) ans++;
        else if(y[i+1] < y[i] && x[i-1] > x[i]) ans++;
    }
        if(y[n-1] < y[n] && x[1] < x[n]) ans++;
        else if(y[1] > y[n] && x[n-1] < x[n]) ans++;
        else if(y[n-1] > y[n] && x[1] > x[n]) ans++;
        else if(y[1] < y[n] && x[n-1] > x[n]) ans++;
    cout << ans << endl;
    return 0;
}


#include<stdio.h>
int main()
{
    int n,x,y;
    scanf("%d",&n);
    for(int i=0;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
    }
    printf("%d\n",(n-4)/2);
}


#include<bits/stdc++.h>
#include<pthread.h>
using namespace std;
#define sc(n) scanf("%d",&n)

int x[1010],y[1010];
int ans=0;
struct node{
        int p,q,r;
};
void *doit(void *arg)
{
        struct node s = *(struct node *)arg;
        int i = s.p;
        int j = s.q;
        int k = s.r;
	int m = (y[j]-y[i])*(x[k]-x[j]) - (x[j] - x[i])*(y[k]-y[j]);
	if(m<0)
		ans++;
}
int main()
{
	int i,j,k;
	int n;
	sc(n);
	pthread_t pid;
	for(i=0;i<=n;i++)
	{
		sc(x[i]);
		sc(y[i]);
	}
	for(i=1;i<n;i++)
	{
		//if(doit(i-1,i,i+1))
		struct node s;
		s.p=i-1;
		s.q=i;
		s.r=i+1;
		pthread_create(&pid,NULL,doit,(void *)&s);
		pthread_join(pid,NULL);
	}
	printf("%d\n",ans );
	return 0;
}


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
 * Created By : Mayank Garg
 * CSE, MNNIT-ALLAHABAD
 *_._._._._._._._._._._._._._._._._._._._.*/

#include<bits/stdc++.h>
using namespace std;

#define test() int t;scanf("%d",&t);for(int tno=1;tno<=t;tno++)

#define mp make_pair
#define pb push_back
#define fl(i,a,b) for(i=a;i<=b;i++)
#define rfl(i,b,a) for(i=b;i>=a;i--)
#define wl(n) while(n--)
#define X first
#define Y second
#define all(c) c.begin(),c.end() //eg sort(all(v));

#define tr(c, itr) for(itr = (c).begin(); itr != (c).end(); itr++)
#define present(container, element) (container.find(element) != container.end()) //for set,map,etc
#define cpresent(container, element) (find(all(container),element) != container.end()) //for vectors

typedef long long ll;
typedef double lf;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > piii ;

#define sz(a) int((a).size())
#define clr(a) memset(a,0,sizeof(a))
#define ini(a) memset(a,-1,sizeof(a))

// Input Output
#define sc(n) scanf("%d",&n)
#define sc2(n,m) sc(n), sc(m)
#define scs(s) scanf("%s",s);
#define pd(n) printf("%d",n)
#define pd2(n,m) printf("%d %d",n,m)
#define scc(n) scanf("%c",&n)
#define infile() freopen("input.txt","r",stdin);
#define output() freopen("output.txt","w",stdout);

#define scl(n) scanf("%lld",&n)
#define scl2(n,m) scanf("%lld%lld",&n,&m)
#define pdl(n) printf("%lld",n)
#define pdl2(n,m) printf("%lld %lld",n,m)
#define newln printf("\n")
#define space printf(" ")

//Bitwise
#define chkbit(s, b)    (s & ((lli)1<<b))
#define setbit(s, b)    (s |= ((lli)1<<b))
#define clrbit(s, b)    (s &= ~(1<<b))

//cost
#define MOD 1000000007
#define MOD_INV 1000000006
#define MAX 100009
#define INF ((1LL<<62)-1)

//Error check
#define debug() printf("here\n")
#define PV(v)       	{ for(int i=0;i<v.size();i++) printf("%d ",v[i]);printf("\n"); }
#define PA(a,st,ed)     { for(int i=st;i<=ed;i++) printf("%d ",a[i]);printf("\n"); }
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl

ll pw(ll base ,ll expo,ll c)
{
	if(expo == 0 )
	return  1 ;
	ll f = pw(base , expo /2,c) ;
	if(expo&1)
	return (((f*f)%c)*base)%c ;
	return (f*f)%c;
}
//-----------------------------------------------------------------------------------------------

int x[1010],y[1010];
int ans=0;
int doit(int i,int j,int k)
{
	int p = (y[j]-y[i])*(x[k]-x[j]) - (x[j] - x[i])*(y[k]-y[j]);
	if(p<0)
		return 1;
	return 0;
}
int main(int argc,char *argv[])
{
	int i,j,k;
	int n;
	sc(n);
	for(i=0;i<=n;i++)
	{
		sc(x[i]);
		sc(y[i]);
	}
	for(i=1;i<n;i++)
	{
		if(doit(i-1,i,i+1))
			ans++;
	}
	printf("%d\n",ans );
	return 0;
}


#include<bits/stdc++.h>
#include<pthread.h>
using namespace std;
void *func(void *arg)
{
        int n = *(int *)arg;
        printf("%d\n",(n-4)/2);

}
int main()
{
        pthread_t pid;
        int n;
        scanf("%d",&n);
        pthread_create(&pid,NULL,func,&n);
        pthread_join(pid,NULL);
        return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;
vector<pair<int, int> > vec;
int judge(int ax, int ay, int bx, int by, int cx, int cy) {
    return (ax - bx) * (cy - by) - (cx  -  bx) * (ay - by);
}
void solve() {
    int n;
    while (cin>>n) {
        for (int i = 0; i <= n; i++) {
            int x,y;
            cin>>x>>y;
            vec.push_back(make_pair(x, y));
        }
        int len = vec.size();
        //vec.push_back(vec[0]);
        int ans = 0;
        for (int i = 1; i < len - 1; i++) {
            if (judge(vec[i-1].first, vec[i-1].second, vec[i].first, vec[i].second, vec[i+1].first, vec[i+1].second) < 0) {
                ans++;
            }
        }
        cout<<ans<<endl;
        vec.clear();
    }
}
int main()
{
    solve();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;
vector<pair<int, int> > vec;
int judge(int ax, int ay, int bx, int by, int cx, int cy) {
    return (ax - bx) * (cy - by) - (cx  -  bx) * (ay - by);
}
void solve() {
    int n;
    while (cin>>n) {
        for (int i = 0; i < n; i++) {
            int x,y;
            cin>>x>>y;
            vec.push_back(make_pair(x, y));
        }
        int len = vec.size();
        vec.push_back(vec[0]);
        int ans = 0;
        for (int i = 1; i < len; i++) {
            if (judge(vec[i-1].first, vec[i-1].second, vec[i].first, vec[i].second, vec[i+1].first, vec[i+1].second) < 0) {
                ans++;
            }
        }
        cout<<ans<<endl;
        vec.clear();
    }
}
int main()
{
    solve();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;
vector<pair<int, int>> vec;
int judge(int ax, int ay, int bx, int by, int cx, int cy) {
    return (ax - bx) * (cy - by) - (cx  -  bx) * (ay - by);
}
void solve() {
    int n;
    while (cin>>n) {
        for (int i = 0; i < n; i++) {
            int x,y;
            cin>>x>>y;
            vec.push_back(make_pair(x, y));
        }
        int len = vec.size();
        vec.push_back(vec[0]);
        int ans = 0;
        for (int i = 1; i < len; i++) {
            if (judge(vec[i-1].first, vec[i-1].second, vec[i].first, vec[i].second, vec[i+1].first, vec[i+1].second) < 0) {
                ans++;
            }
        }
        cout<<ans<<endl;
        vec.clear();
    }
}
int main()
{
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
vector <char> d;
vector <pair<ll,ll> > v;

int main()
{
ll dir,n,i,x,y,ans=0;
cin>>n;
for(i=0;i<=n;i++)
{
    cin>>x>>y;
    v.pb(mp(x,y));
}
    for(i=0;i<v.size()-1;i++)
    {
        if(v[i].first==v[i+1].first&&v[i].second<v[i+1].second)
            d.pb('n');
        else if(v[i].first==v[i+1].first&&v[i].second>v[i+1].second)
            d.pb('s');
        else if(v[i].first<v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('e');
            else if(v[i].first>v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('w');
    }

for(i=0;i<d.size()-1;i++)
{
    if(d[i]=='e'&&d[i+1]=='n')
        ans++;
    else if(d[i]=='n'&&d[i+1]=='w')
        ans++;
    else if(d[i]=='w'&&d[i+1]=='s')
        ans++;
    else if(d[i]=='s'&&d[i+1]=='e')
        ans++;

}

cout<<ans;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define clockwise 0
#define anticlockwise 1
vector <char> d;
vector <pair<ll,ll> > v;

int main()
{
ll dir,n,i,x,y,ans=0;
cin>>n;
for(i=0;i<=n;i++)
{
    cin>>x>>y;
    v.pb(mp(x,y));
}
if(v[2].first>v[1].first)
    dir=clockwise;
else
    dir=anticlockwise;

    for(i=0;i<v.size()-1;i++)
    {
        if(v[i].first==v[i+1].first&&v[i].second<v[i+1].second)
            d.pb('n');
        else if(v[i].first==v[i+1].first&&v[i].second>v[i+1].second)
            d.pb('s');
        else if(v[i].first<v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('e');
            else if(v[i].first>v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('w');
    }

if(dir==clockwise)//count all the turn left points
{

for(i=0;i<d.size()-1;i++)
{
    if(d[i]=='e'&&d[i+1]=='n')
        ans++;
    else if(d[i]=='n'&&d[i+1]=='w')
        ans++;
    else if(d[i]=='w'&&d[i+1]=='s')
        ans++;
    else if(d[i]=='s'&&d[i+1]=='e')
        ans++;

}

}

else
{
for(i=0;i<d.size()-1;i++)
{
    if(d[i]=='n'&&d[i+1]=='e')
        ans++;
    else if(d[i]=='w'&&d[i+1]=='n')
        ans++;
    else if(d[i]=='s'&&d[i+1]=='w')
        ans++;
    else if(d[i]=='e'&&d[i+1]=='s')
        ans++;

}

}
cout<<ans;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define clockwise 0
#define anticlockwise 1
vector <char> d;
vector <pair<ll,ll> > v;

int main()
{
ll dir,n,i,x,y,ans=0;
cin>>n;
for(i=0;i<=n;i++)
{
    cin>>x>>y;
    v.pb(mp(x,y));
}
v.pb(mp(v[0].first,v[0].second));
if(v[2].first>v[1].first)
    dir=clockwise;
else
    dir=anticlockwise;

    for(i=0;i<v.size()-1;i++)
    {
        if(v[i].first==v[i+1].first&&v[i].second<v[i+1].second)
            d.pb('n');
        else if(v[i].first==v[i+1].first&&v[i].second>v[i+1].second)
            d.pb('s');
        else if(v[i].first<v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('e');
            else if(v[i].first>v[i+1].first&&v[i].second==v[i+1].second)
            d.pb('w');
    }

if(dir==clockwise)//count all the turn left points
{

for(i=0;i<d.size()-1;i++)
{
    if(d[i]=='e'&&d[i+1]=='n')
        ans++;
    else if(d[i]=='n'&&d[i+1]=='w')
        ans++;
    else if(d[i]=='w'&&d[i+1]=='s')
        ans++;
    else if(d[i]=='s'&&d[i+1]=='e')
        ans++;

}

}

else
{
for(i=0;i<d.size()-1;i++)
{
    if(d[i]=='n'&&d[i+1]=='e')
        ans++;
    else if(d[i]=='w'&&d[i+1]=='n')
        ans++;
    else if(d[i]=='s'&&d[i+1]=='w')
        ans++;
    else if(d[i]=='e'&&d[i+1]=='s')
        ans++;

}

}
cout<<ans;

return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int n, m, a[100005];
int avai[200005];

int check(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    if(x1 == x2){
        if(x3 == x4) return false;
        if((x3 - x2) * (x4 - x2) < 0 && (y2 - y1) * (y2 - y3) < 0) return true;
        return false;
    }
    if(y1 == y2){
        if(y3 == y4) return false;
        if((y3 - y2) * (y4 - y2) < 0 && (x2 - x1) * (x2 - x3) < 0) return true;
        return false;
    }
}

int main() {
    int n, x[1005], y[1005], res = 0;
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>x[i]>>y[i];
    x[n+1] = x[1];
    y[n+1] = y[1];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i != j && check(x[i], y[i], x[i+1], y[i+1], x[j], y[j], x[j+1], y[j+1])){
                res++;
                break;
            }
        }
    }
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int check(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    if(x1 == x2){
        if(x3 == x4) return false;
        if((x3 - x2) * (x4 - x2) < 0 && (y2 - y1) * (y2 - y3) < 0) return true;
        return false;
    }
    if(y1 == y2){
        if(y3 == y4) return false;
        if((y3 - y2) * (y4 - y2) < 0 && (x2 - x1) * (x2 - x3) < 0) return true;
        return false;
    }
}

int main() {
    int n;
    long long x[1005], y[1005], res = 0;
    cin>>n;
    n++;
    for(int i = 1; i <= n; i++) cin>>x[i]>>y[i];
    x[0] = x[n];
    y[0] = y[n];
    x[n+1] = x[2];
    y[n+1] = y[2];
    if(n == 4) cout<<0;
    else{
        for(int i = 1; i <= n; i++){
            int check = 0;
            if(x[i] > x[i-1] && y[i+1] > y[i]) check++;
            if(x[i] < x[i-1] && y[i] > y[i+1]) check++;
            if(x[i] > x[i+1] && y[i] > y[i-1]) check++;
            if(x[i] < x[i+1] && y[i] < y[i-1]) check++;
            if(check > 0) res++;
        }
    cout<<res;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int check(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, ll x4, ll y4){
    if(x1 == x2){
        if(x3 == x4) return false;
        if((x3 - x2) * (x4 - x2) < 0 && (y2 - y1) * (y2 - y3) < 0) return true;
    }
    if(y1 == y2){
        if(y3 == y4) return false;
        if((y3 - y2) * (y4 - y2) < 0 && (x2 - x1) * (x2 - x3) < 0) return true;
    }
    return false;
}

int main() {
    int n;
    ll x[1005], y[1005], res = 0;
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>x[i]>>y[i];
    x[n+1] = x[1];
    y[n+1] = y[1];
    if(n == 4) cout<<0;
    else{
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(i != j && check(x[i], y[i], x[i+1], y[i+1], x[j], y[j], x[j+1], y[j+1])){
                    res++;
                    break;
                }
            }
        }
    cout<<res;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int check(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    if(x1 == x2){
        if(x3 == x4) return false;
        if((x3 - x2) * (x4 - x2) < 0 && (y2 - y1) * (y2 - y3) < 0) return true;
        return false;
    }
    if(y1 == y2){
        if(y3 == y4) return false;
        if((y3 - y2) * (y4 - y2) < 0 && (x2 - x1) * (x2 - x3) < 0) return true;
        return false;
    }
}

int main() {
    int n;
    long long x[1005], y[1005], res = 0;
    cin>>n;
    n++;
    for(int i = 1; i <= n; i++) cin>>x[i]>>y[i];
    x[n+1] = x[1];
    y[n+1] = y[1];
    if(n == 4) cout<<0;
    else{
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(i != j && check(x[i], y[i], x[i+1], y[i+1], x[j], y[j], x[j+1], y[j+1])){
                    res++;
                    break;
                }
            }
        }
    cout<<res;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-8;
const double inf = 1e5;
const double pi = acos(-1.0);
int sgn(double x)
{
    if(fabs(x) < eps)return 0;
    else if(x < 0)return -1;
    return 1;
}

struct Point
{
    double x,y;
    Point(){}
    Point(double _x,double _y){x=_x;y=_y;}
};

struct Line
{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e)
    {
        s = _s;e = _e;
    }

};

typedef Point Vectors;
Vectors operator + (Vectors A,Vectors B){return Vectors(A.x+B.x, A.y+B.y);}
Vectors operator - (Point A,Point B){return Vectors(A.x-B.x, A.y-B.y);}
double Cross(Vectors A, Vectors B){return A.x*B.y-A.y*B.x;}
double Dot(Vectors A, Vectors B){return A.x*B.x + A.y*B.y;}
double xmult(Point p0,Point p1,Point p2) //p0p1 X p0p2
{
    Vectors V1,V2;
    V1=p1-p0;
    V2=p2-p0;
    return Cross(V1,V2);
}

int N;
Point p[1100];
int main()
{
    while(~scanf("%d",&N))
    {
        double tx,ty;
        for(int i = 0; i < N; i++)
        {
            scanf("%lf %lf",&tx,&ty);
            p[i]=Point(tx,ty);
        }
        scanf("%lf %lf",&tx,&ty);
        int num=0;
        for(int i = 2; i < N; i++)
        {
            if(sgn(xmult(p[i-2],p[i],p[i-1]))<0)num++;
        }
        printf("%d\n",num);
    }
    //system("pause");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-8;
const double inf = 1e5;
const double pi = acos(-1.0);
int sgn(double x)
{
    if(fabs(x) < eps)return 0;
    else if(x < 0)return -1;
    return 1;
}

struct Point
{
    double x,y;
    Point(){}
    Point(double _x,double _y){x=_x;y=_y;}
};

struct Line
{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e)
    {
        s = _s;e = _e;
    }

};

typedef Point Vectors;
Vectors operator + (Vectors A,Vectors B){return Vectors(A.x+B.x, A.y+B.y);}
Vectors operator - (Point A,Point B){return Vectors(A.x-B.x, A.y-B.y);}
double Cross(Vectors A, Vectors B){return A.x*B.y-A.y*B.x;}
double Dot(Vectors A, Vectors B){return A.x*B.x + A.y*B.y;}
double xmult(Point p0,Point p1,Point p2) //p0p1 X p0p2
{
    Vectors V1,V2;
    V1=p1-p0;
    V2=p2-p0;
    return Cross(V1,V2);
}

int N;
Point p[1100];
int main()
{
    while(~scanf("%d",&N))
    {
        double tx,ty;
        for(int i = 0; i < N; i++)
        {
            scanf("%lf %lf",&tx,&ty);
            p[i]=Point(tx,ty);
        }
        scanf("%lf %lf",&tx,&ty);
        int num=0;
        for(int i = 2; i < N; i++)
        {
            if(sgn(xmult(p[i-2],p[i],p[i-1]))<0)num++;
        }
        printf("%d\n",num);
    }
    system("pause");
    return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
// #define TURN_EAST 1
// #define TURN_WEST 2
// #define TURN_NORTH 3
// #define TURN_SOUTH 4
int EAST=-1;
int WEST =-2;
int NORTH =-3;
int  SOUTH =-4;
int x[2000],y[2000];
int fetch_dir(int a,int b)
{
  if(x[a]==x[b])
  {
    if(y[a]>y[b])
      return SOUTH;
    return NORTH;
  }
  if(y[a]==y[b])
  {
    if(x[a]>x[b])
      return WEST;
    return EAST;
  }
  return -1;
}
int fetch_final_direction(int last,int first)
{
    int prev_dir=fetch_dir(last,first);
    return prev_dir;
}
int is_danger_turn(int current_dir,int turned_dir,vector< pair<int,int> >danger_turns)
{

  for(int i=0;i<danger_turns.size();i++)
  {
    if(danger_turns[i].first==current_dir && danger_turns[i].second==turned_dir)
      return 1;
  }
  return 0;

}
int count_turns(int current,int n,int dir,vector< pair<int,int> >danger_turns)
{
  if(current>=n-1)
    return 0;
  int turned_dir=fetch_dir(current+1,current+2);
  if(is_danger_turn(dir,turned_dir,danger_turns))
      return 1+count_turns(current+1,n,turned_dir,danger_turns);
  return count_turns(current+1,n,turned_dir,danger_turns);

}
int main()
{
    int i,n;
    vector< pair<int,int> > danger_turns;
    cin>>n;
    for(i=0;i<=n;i++)
    {
      cin>>x[i]>>y[i];
    }
    int dir=NORTH;
    int final_dir=fetch_final_direction(n-1,n);
    if(final_dir==WEST)
    {
      // cout<<"WEST\n";
      danger_turns.pb(mk(EAST,NORTH));
      danger_turns.pb(mk(WEST,SOUTH));
      danger_turns.pb(mk(SOUTH,EAST));
      danger_turns.pb(mk(NORTH,WEST));

    }
    else
    {
      // cout<<"EAST\n";
      danger_turns.pb(mk(NORTH,EAST));
      danger_turns.pb(mk(EAST,SOUTH));
      danger_turns.pb(mk(SOUTH,WEST));
      danger_turns.pb(mk(WEST,NORTH));

    }
    int num_danger_turns=count_turns(0,n,NORTH,danger_turns);
    cout<<num_danger_turns<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define north 1
#define east 2
#define west 3
#define south 4
#define x first
#define y second
#define INF 1000000
#define Point pair<int,int>
/*
struct Point
{
    int x;
    int y;
    Point(int a,int b)
    {
    	struct Point temp=(struct Point)malloc(sizeof(struct Point));
    	temp.x=a;
    	temp.y=b;
    	return temp;
    }
};

 */
// Given three colinear points p, q, r, the function checks if
// point q lies on line segment 'pr'
bool onSegment(Point p, Point q, Point r)
{
//	cout<<p.x<<" "<<p.y<<endl<<q.x<<" "<<q.y<<endl<<r.x<<" "<<r.y<<endl<<endl;

    if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) &&
            q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y))
        return true;
    return false;
}

// To find orientation of ordered triplet (p, q, r).
// The function returns following values
// 0 --> p, q and r are colinear
// 1 --> Clockwise
// 2 --> Counterclockwise
int orientation(Point p, Point q, Point r)
{
    int val = (q.y - p.y) * (r.x - q.x) -
              (q.x - p.x) * (r.y - q.y);

    if (val == 0) return 0;  // colinear
    return (val > 0)? 1: 2; // clock or counterclock wise
}

// The function that returns true if line segment 'p1q1'
// and 'p2q2' intersect.
bool doIntersect(Point p1, Point q1, Point p2, Point q2)
{
    // Find the four orientations needed for general and
    // special cases
    int o1 = orientation(p1, q1, p2);
    int o2 = orientation(p1, q1, q2);
    int o3 = orientation(p2, q2, p1);
    int o4 = orientation(p2, q2, q1);

    // General case
    if (o1 != o2 && o3 != o4)
        return true;

    // Special Cases
    // p1, q1 and p2 are colinear and p2 lies on segment p1q1
    if (o1 == 0 && onSegment(p1, p2, q1)) return true;

    // p1, q1 and p2 are colinear and q2 lies on segment p1q1
    if (o2 == 0 && onSegment(p1, q2, q1)) return true;

    // p2, q2 and p1 are colinear and p1 lies on segment p2q2
    if (o3 == 0 && onSegment(p2, p1, q2)) return true;

     // p2, q2 and q1 are colinear and q1 lies on segment p2q2
    if (o4 == 0 && onSegment(p2, q1, q2)) return true;

    return false; // Doesn't fall in any of the above cases
}

// Returns true if the point p lies inside the polygon[] with n vertices
bool IsInside(vector< Point> polygon, int n, Point p)
{
    // There must be at least 3 vertices in polygon[]
  //  cout<<"beg"<<p.x<<" "<<p.y<<endl;
    if (n < 3)  return false;

    // Create a point for line segment from p to infinite
    Point extreme = mk(INF, p.y);

    // Count intersections of the above line with sides of polygon
    int count = 0, i = 0;
    do
    {
        int next = (i+1)%n;

        // Check if the line segment from 'p' to 'extreme' intersects
        // with the line segment from 'polygon[i]' to 'polygon[next]'
        if(p.x==polygon[i].x || p.y==polygon[i].y ||p.x==polygon[next].x || p.y==polygon[next].y )
        {
        }
		else if (doIntersect(polygon[i], polygon[next], p, extreme))
        {
            // If the point 'p' is colinear with line segment 'i-next',
            // then check if it lies on segment. If it lies, return true,
            // otherwise false
   			//
			   //cout<<polygon[i].x<<" "<<polygon[i].y<<" "<<polygon[next].x<<" "<<polygon[next].y<<endl;

	        if (orientation(p,polygon[i], polygon[next]) == 0)
             {
               /*onSegment(polygon[i], p, polygon[next]) )
               {

               }
               else
               	count++;*/
            }
            else
            {
 			//		cout<<polygon[i].x<<" "<<polygon[i].y<<" "<<polygon[next].x<<" "<<polygon[next].y<<endl;

            	count++;
 			}
        }
        /*
        if (doIntersect(polygon[i], polygon[next], p, extreme))
        {

	         if (orientation(polygon[i], p, polygon[next]) == 0)
            	{

            		int val=onSegment(polygon[i], p, polygon[next]);
            	//	cout<<"-----"<<val<<endl;
            //		return val;
            	}
            	else
            	{
            		cout<<polygon[i].x<<" "<<polygon[i].y<<" "<<polygon[next].x<<" "<<polygon[next].y<<endl;
 	      		 	count++;
 	      		 }
        }*/
        i = next;
    } while (i != 0);

    // Return true if count is odd, false otherwise
    int v=count&1;  // Same as (count%2 == 1)
//	cout<<"*********\n";
//	cout<<p.x<<" "<<p.y<<endl;
	cout<<count<<" "<<v<<endl;
}
int find_dir(Point p1,Point p2)
{
	if(p1.x==p2.x)
	{
		if(p2.y>p1.y)
			return north;
		else
			return south;
	}
	else
	{
		if(p2.x>p1.x)
			return east;
		return west;

	}
}
int main()
{
	int dir2,n,a,b,dir,i,ans=0;
	cin>>n;
	vector<pair<int,int> >p;
	for(i=0;i<n+1;i++)
	{
		cin>>a>>b;
		p.pb(mk(a*2,b*2));
	}
	dir=north;
	for(i=1;i<n;i++)
	{
		dir2=find_dir(p[i],p[i+1]);

		if(dir==north && dir2==east)
		{
			Point p2=mk(p[i].x-1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y+1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==north && dir2==west)
		{
			Point p2=mk(p[i].x+1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y+1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==south && dir2==east)
		{
			Point p2=mk(p[i].x-1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y-1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==south && dir2==west)
		{
			Point p2=mk(p[i].x+1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y-1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==east && dir2==north)
		{
			Point p2=mk(p[i].x,p[i].y-1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x+1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==east && dir2==south)
		{
			Point p2=mk(p[i].x,p[i].y+1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x+1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==west && dir2==north)
		{
			Point p2=mk(p[i].x,p[i].y-1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x-1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==west && dir2==south)
		{
			Point p2=mk(p[i].x,p[i].y+1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x-1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		dir=dir2;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define north 1
#define east 2
#define west 3
#define south 4
#define x first
#define y second
#define INF 1000000
#define Point pair<int,int>
/*
struct Point
{
    int x;
    int y;
    Point(int a,int b)
    {
    	struct Point temp=(struct Point)malloc(sizeof(struct Point));
    	temp.x=a;
    	temp.y=b;
    	return temp;
    }
};

 */
// Given three colinear points p, q, r, the function checks if
// point q lies on line segment 'pr'
bool onSegment(Point p, Point q, Point r)
{
    if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) &&
            q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y))
        return true;
    return false;
}

// To find orientation of ordered triplet (p, q, r).
// The function returns following values
// 0 --> p, q and r are colinear
// 1 --> Clockwise
// 2 --> Counterclockwise
int orientation(Point p, Point q, Point r)
{
    int val = (q.y - p.y) * (r.x - q.x) -
              (q.x - p.x) * (r.y - q.y);

    if (val == 0) return 0;  // colinear
    return (val > 0)? 1: 2; // clock or counterclock wise
}

// The function that returns true if line segment 'p1q1'
// and 'p2q2' intersect.
bool doIntersect(Point p1, Point q1, Point p2, Point q2)
{
    // Find the four orientations needed for general and
    // special cases
    int o1 = orientation(p1, q1, p2);
    int o2 = orientation(p1, q1, q2);
    int o3 = orientation(p2, q2, p1);
    int o4 = orientation(p2, q2, q1);

    // General case
    if (o1 != o2 && o3 != o4)
        return true;

    // Special Cases
    // p1, q1 and p2 are colinear and p2 lies on segment p1q1
    if (o1 == 0 && onSegment(p1, p2, q1)) return true;

    // p1, q1 and p2 are colinear and q2 lies on segment p1q1
    if (o2 == 0 && onSegment(p1, q2, q1)) return true;

    // p2, q2 and p1 are colinear and p1 lies on segment p2q2
    if (o3 == 0 && onSegment(p2, p1, q2)) return true;

     // p2, q2 and q1 are colinear and q1 lies on segment p2q2
    if (o4 == 0 && onSegment(p2, q1, q2)) return true;

    return false; // Doesn't fall in any of the above cases
}

// Returns true if the point p lies inside the polygon[] with n vertices
bool IsInside(vector< Point> polygon, int n, Point p)
{
    // There must be at least 3 vertices in polygon[]
    if (n < 3)  return false;

    // Create a point for line segment from p to infinite
    Point extreme = mk(INF, p.y);

    // Count intersections of the above line with sides of polygon
    int count = 0, i = 0;
    do
    {
        int next = (i+1)%n;

        // Check if the line segment from 'p' to 'extreme' intersects
        // with the line segment from 'polygon[i]' to 'polygon[next]'
        if (doIntersect(polygon[i], polygon[next], p, extreme))
        {
            // If the point 'p' is colinear with line segment 'i-next',
            // then check if it lies on segment. If it lies, return true,
            // otherwise false
            if (orientation(polygon[i], p, polygon[next]) == 0)
               return onSegment(polygon[i], p, polygon[next]);

            count++;
        }
        i = next;
    } while (i != 0);

    // Return true if count is odd, false otherwise
    return count&1;  // Same as (count%2 == 1)
}
int find_dir(Point p1,Point p2)
{
	if(p1.x==p2.x)
	{
		if(p2.y>p1.y)
			return north;
		else
			return south;
	}
	else
	{
		if(p2.x>p1.x)
			return east;
		return west;

	}
}
int main()
{
	int dir2,n,a,b,dir,i,ans=0;
	cin>>n;
	vector<pair<int,int> >p;
	for(i=0;i<n+1;i++)
	{
		cin>>a>>b;
		p.pb(mk(a*2,b*2));
	}
	dir=north;
	for(i=1;i<n;i++)
	{
		dir2=find_dir(p[i],p[i+1]);

		if(dir==north && dir2==east)
		{
			Point p2=mk(p[i].x-1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y+1);
			if(IsInside(p,n,p2))
				ans++;
			}
		}
		if(dir==north && dir2==west)
		{
			Point p2=mk(p[i].x+1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y+1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==south && dir2==east)
		{
			Point p2=mk(p[i].x-1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y-1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==south && dir2==west)
		{
			Point p2=mk(p[i].x+1,p[i].y);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x,p[i].y-1);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==east && dir2==north)
		{
			Point p2=mk(p[i].x,p[i].y-1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x+1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==east && dir2==south)
		{
			Point p2=mk(p[i].x,p[i].y+1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x+1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==west && dir2==north)
		{
			Point p2=mk(p[i].x,p[i].y-1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x-1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		if(dir==west && dir2==south)
		{
			Point p2=mk(p[i].x,p[i].y+1);
			if(IsInside(p,n,p2))
				ans++;
			else
			{
				p2=mk(p[i].x-1,p[i].y);
				if(IsInside(p,n,p2))
					ans++;
			}
		}
		dir=dir2;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define openfile ({freopen("circles.inp", "r", stdin); freopen("circles.out", "w", stdout);})

typedef pair<int,int> II;
typedef long long LL;

const long double pi=2*acos(0);
const int N=111111;
const int MOD=1e9+7;

int n;
int x[1111],y[1111];

main()
{ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  LL cnt=0;
  cin >> n;
  for(int i=0;i<=n;++i) cin >> x[i] >> y[i];
  for(int i=1;i<n-1;++i)
  { if(y[i]==y[i-1])
    { if(x[i-1]<x[i])
      { if(y[i+1]>y[i]) cnt++;
      }
      if(x[i-1]>x[i])
      { if(y[i+1]<y[i]) cnt++;

      }
    }
    if(y[i]==y[i+1])
    { if(y[i-1]>y[i]) cnt++;

    }
  }
  cout << cnt;

}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define openfile ({freopen("circles.inp", "r", stdin); freopen("circles.out", "w", stdout);})

typedef pair<int,int> II;
typedef long long LL;

const long double pi=2*acos(0);
const int N=111111;
const int MOD=1e9+7;

int n;
int x[1111],y[1111];

main()
{ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  LL cnt=0;
  cin >> n;
  for(int i=0;i<=n;++i) cin >> x[i] >> y[i];
  for(int i=1;i<n-1;++i)
  { if(y[i]==y[i-1])
    { if(x[i-1]<x[i])
      { if(y[i+1]>y[i]) cnt++;
      }
      if(x[i-1]>x[i])
      { if(y[i+1]<y[i]) cnt++;

      }
    }
    if(y[i]==y[i+1])
    { if(y[i-1]>y[i]) cnt++;
      if(y[i-1]<y[i]) cnt++;
    }
  }
  cout << cnt;

}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define openfile ({freopen("circles.inp", "r", stdin); freopen("circles.out", "w", stdout);})

typedef pair<int,int> II;
typedef long long LL;

const long double pi=2*acos(0);
const int N=111111;
const int MOD=1e9+7;

int n;
int x[1111],y[1111];

main()
{ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  LL cnt=0;
  cin >> n;
  for(int i=0;i<=n;++i) cin >> x[i] >> y[i];
  for(int i=1;i<n-1;++i)
  { if(y[i]==y[i-1])
    { if(x[i-1]<x[i])
      { if(y[i+1]>y[i]) cnt++;//,cout << i << endl;
      }
      if(x[i-1]>x[i])
      { if(y[i+1]<y[i]) cnt++;//,cout << i << endl;

      }
    }
    if(y[i]==y[i+1])
    { if(x[i]<x[i+1])
      { if(y[i-1]>y[i]) cnt++;//,cout << i << endl;
      }
      if(x[i]>x[i+1])
      { if(y[i-1]<y[i]) cnt++;//,cout << i << endl;;
      }

    }
  }
  cout << cnt;

}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)2e3+4
using namespace std;
vector<pii> S;
bool vis[N];
vector<int> dir;
int fin[N];
void solve(){
    int n;
    cin>>n;
    int stx=1e9,sty=1e9,idx=-1;
    for(int i=0;i<n+1;i++){
        int x,y;
        cin>>x>>y;
        if(sty>y){
            sty=y;
            stx=x;
            idx=i;
        }
        else if(sty==y){
            sty=y;
            stx=x;
            idx=i;
        }
        S.pb(mp(x,y));
    }
    int x=0;
    vis[idx]=1;
    int cnt=1;
    int miny=1e9;
    idx=-1;
    for(int i=0;i<S.size();i++){
        if(vis[idx]==1)
            continue;
        if(stx==S[i].fi&&S[i].se>sty){
           miny=min(miny,S[i].se);
           idx=i;
        }
    }
    vis[idx]=1;
    sty=miny;
    x=1;
    cnt++;
    int ans=0;
    dir.pb(0);
    while(cnt<n+1){
         idx=-1;
         if(x==1){
            int minx=1e9,maxx=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].se==sty){
                    if(S[i].fi>stx&&(f==-1||f==1)){
                       minx=min(S[i].fi,minx);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].fi<stx&&(f==-1||f==0)){
                        maxx=max(maxx,S[i].fi);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxx==-1e9){
                stx=minx;
                x=0;
                dir.pb(3);
            }
            else{
                stx=maxx;
                x=0;
                dir.pb(2);
            }
            continue;
         }
         if(x==0){
            int miny=1e9,maxy=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].fi==stx){
                    if(S[i].se>sty&&(f==-1||f==1)){
                       miny=min(S[i].se,miny);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].se<sty&&(f==-1||f==0)){
                        maxy=max(maxy,S[i].se);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxy==-1e9){
               sty=miny;
               x=1;
               dir.pb(0);
            }
            else{
                sty=maxy;
                x=1;
                dir.pb(1);
            }
         }
    }
    for(int i=0;i<dir.size();i++){
        int fi=i,nx;
        if(i+2<dir.size()){
           nx=i+2;
        }
        else{
            if(i+2==n+1){
                nx=1;
            }
            else{
                nx=0;
            }
        }
        if(dir[fi]==0&&dir[nx]==1){
           fin[fi]=2;
           fin[nx]=3;
        }
        if(dir[fi]==1&&dir[nx]==0){
           fin[fi]=3;
           fin[nx]=2;
        }
        if(dir[fi]==2&&dir[nx]==3){
            fin[fi]=0;
            fin[nx]=1;
        }
        if(dir[fi]==3&&dir[nx]==2){
            fin[fi]=1;
            fin[nx]=0;
        }
    }
    for(int i=0;i<dir.size()-1;i++){
        if(dir[i]==fin[i+1]){
            ans++;
        }
    }
    cout<<ans;
}
int main(){
   //ios_base::sync_with_stdio(false);
   int t=1;
   //scanf("%d",&t);
   for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)2e3+4
using namespace std;
vector<pii> S;
bool vis[N];
vector<int> dir;
int fin[N];
void solve(){
    int n;
    cin>>n;
    int stx=1e9,sty=1e9,idx=-1;
    for(int i=0;i<n+1;i++){
        int x,y;
        cin>>x>>y;
        if(sty>y){
            sty=y;
            stx=x;
            idx=i;
        }
        else if(sty==y){
            if(stx>x){
                stx=x;
                sty=y;
                idx=i;
            }
        }
        S.pb(mp(x,y));
    }
    int x=0;
    vis[idx]=1;
    int cnt=1;
    int miny=1e9;
    idx=-1;
    for(int i=0;i<S.size();i++){
        if(vis[idx]==1)
            continue;
        if(stx==S[i].fi&&S[i].se>sty){
           miny=min(miny,S[i].se);
           idx=i;
        }
    }
    vis[idx]=1;
    sty=miny;
    x=1;
    cnt++;
    int ans=0;
    dir.pb(0);
    while(cnt<n+1){
         idx=-1;
         if(x==1){
            int minx=1e9,maxx=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].se==sty){
                    if(S[i].fi>stx&&(f==-1||f==1)){
                       minx=min(S[i].fi,minx);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].fi<stx&&(f==-1||f==0)){
                        maxx=max(maxx,S[i].fi);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxx==-1e9){
                stx=minx;
                x=0;
                dir.pb(3);
            }
            else{
                stx=maxx;
                x=0;
                dir.pb(2);
            }
            continue;
         }
         if(x==0){
            int miny=1e9,maxy=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].fi==stx){
                    if(S[i].se>sty&&(f==-1||f==1)){
                       miny=min(S[i].se,miny);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].se<sty&&(f==-1||f==0)){
                        maxy=max(maxy,S[i].se);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxy==-1e9){
               sty=miny;
               x=1;
               dir.pb(0);
            }
            else{
                sty=maxy;
                x=1;
                dir.pb(1);
            }
         }
    }
    for(int i=0;i<dir.size();i++){
        int fi=i,nx;
        if(i+2<dir.size()){
           nx=i+2;
        }
        else{
            if(i+2==n+1){
                nx=1;
            }
            else{
                nx=0;
            }
        }
        if(dir[fi]==0&&dir[nx]==1){
           fin[fi]=3;
           fin[nx]=2;
        }
        if(dir[fi]==1&&dir[nx]==0){
           fin[fi]=2;
           fin[nx]=3;
        }
        if(dir[fi]==2&&dir[nx]==3){
            fin[fi]=0;
            fin[nx]=1;
        }
        if(dir[fi]==3&&dir[nx]==2){
            fin[fi]=1;
            fin[nx]=0;
        }
    }
    for(int i=0;i<dir.size()-1;i++){
        if(dir[i]==fin[i+1]){
            ans++;
        }
    }
    cout<<ans;
}
int main(){
   //ios_base::sync_with_stdio(false);
   int t=1;
   //scanf("%d",&t);
   for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)2e3+4
using namespace std;
vector<pii> S;
bool vis[N];
vector<int> dir;
int fin[N];
void solve(){
    int n;
    cin>>n;
    int stx=1e9,sty=1e9,idx=-1;
    for(int i=0;i<n+1;i++){
        int x,y;
        cin>>x>>y;
        if(sty>y){
            sty=y;
            stx=x;
            idx=i;
        }
        else if(sty==y){
            sty=y;
            stx=x;
            idx=i;
        }
        S.pb(mp(x,y));
    }
    int x=0;
    vis[idx]=1;
    int cnt=1;
    int miny=1e9;
    idx=-1;
    for(int i=0;i<S.size();i++){
        if(vis[idx]==1)
            continue;
        if(stx==S[i].fi&&S[i].se>sty){
           miny=min(miny,S[i].se);
           idx=i;
        }
    }
    vis[idx]=1;
    sty=miny;
    x=1;
    cnt++;
    int ans=0;
    dir.pb(0);
    while(cnt<n+1){
         idx=-1;
         if(x==1){
            int minx=1e9,maxx=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].se==sty){
                    if(S[i].fi>stx&&(f==-1||f==1)){
                       minx=min(S[i].fi,minx);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].fi<stx&&(f==-1||f==0)){
                        maxx=max(maxx,S[i].fi);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxx==-1e9){
                stx=minx;
                x=0;
                dir.pb(3);
            }
            else{
                stx=maxx;
                x=0;
                dir.pb(2);
            }
            continue;
         }
         if(x==0){
            int miny=1e9,maxy=-1e9,f=-1;
            for(int i=0;i<S.size();i++){
                if(vis[idx]==1){
                    continue;
                }
                if(S[i].fi==stx){
                    if(S[i].se>sty&&(f==-1||f==1)){
                       miny=min(S[i].se,miny);
                       f=1;
                       idx=i;
                    }
                    else if(S[i].se<sty&&(f==-1||f==0)){
                        maxy=max(maxy,S[i].se);
                        f=0;
                        idx=i;
                    }
                }
            }
            cnt++;
            vis[idx]=1;
            if(maxy==-1e9){
               sty=miny;
               x=1;
               dir.pb(0);
            }
            else{
                sty=maxy;
                x=1;
                dir.pb(1);
            }
         }
    }
    for(int i=0;i<dir.size();i++){
        int fi=i,nx;
        if(i+2<dir.size()){
           nx=i+2;
        }
        else{
            if(i+2==n+1){
                nx=1;
            }
            else{
                nx=0;
            }
        }
        if(dir[fi]==0&&dir[nx]==1){
           fin[fi]=3;
           fin[nx]=2;
        }
        if(dir[fi]==1&&dir[nx]==0){
           fin[fi]=2;
           fin[nx]=3;
        }
        if(dir[fi]==2&&dir[nx]==3){
            fin[fi]=0;
            fin[nx]=1;
        }
        if(dir[fi]==3&&dir[nx]==2){
            fin[fi]=1;
            fin[nx]=0;
        }
    }
    for(int i=0;i<dir.size()-1;i++){
        if(dir[i]==fin[i+1]){
            ans++;
        }
    }
    cout<<ans;
}
int main(){
   //ios_base::sync_with_stdio(false);
   int t=1;
   //scanf("%d",&t);
   for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define N (int)2e3+4
using namespace std;
vector<pii> S;
bool vis[N];
vector<int> dir;
int fin[N];
void solve(){
    int n;
    cin>>n;
    int stx=1e9,sty=1e9,idx=-1;
    for(int i=0;i<n+1;i++){
        int x,y;
        cin>>x>>y;
        S.pb(mp(x,y));
    }
    for(int i=1;i<S.size();i++){
        if(S[i].fi==S[i-1].fi){
            if(S[i].se>S[i-1].se){
                dir.pb(0);
            }
            else{
                dir.pb(1);
            }
        }
        else{
            if(S[i].fi>S[i-1].fi){
                dir.pb(3);
            }
            else{
                dir.pb(2);
            }
        }
    }
    dir.pb(0);
    int ans=0;
    for(int i=0;i<dir.size()-1;i++){
        if(dir[i]==0&&dir[i+1]==2){
           ans++;
        }
        if(dir[i]==1&&dir[i+1]==3){
           ans++;
        }
        if(dir[i]==2&&dir[i+1]==1){
           ans++;
        }
        if(dir[i]==3&&dir[i+1]==0){
           ans++;
        }
    }
    cout<<ans;
}
int main(){
   //ios_base::sync_with_stdio(false);
   int t=1;
   //scanf("%d",&t);
   for(int i=1;i<=t;i++){
       //printf("Case #%d: ",i);
       solve();
   }
   return 0;
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;

int main(){
  std::ios::sync_with_stdio(false);

  vector < bitset<21000> > maze(21000);

  int n;

  cin >> n;

  int a, b;

  vector< pair<int, int> > pts(n+1);
  vector<string> dir;

  for (int i = 0; i <=n ; ++i)
  {
    cin >> a >> b;
  }

  ll d = (90*n - 360)/180;

  cout << d << endl;

  return 0;
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;

int main(){
  std::ios::sync_with_stdio(false);

  vector < bitset<21000> > maze(21000);

  int n;

  cin >> n;

  int a, b;

  vector< pair<int, int> > pts(n+1);
  vector<string> dir;

  for (int i = 0; i <=n ; ++i)
  {
    cin >> a >> b;
    pts[i] = make_pair(a, b);

    if(i > 0){
      //east
      if(pts[i].first > pts[i-1].first){
        dir.pb("e");
      }

      //west
      else if(pts[i].first < pts[i-1].first){
        dir.pb("w");
      }

      //north
      else if(pts[i].second > pts[i-1].second){
        dir.pb("n");
      }

      //south
      else if(pts[i].second < pts[i-1].second){
        dir.pb("s");
      }
    }
  }

  ll d = 0;

  for (int i = 0; i < dir.size(); i++)
  {
    int a=i, b=i-1, c=i-2;
    if(b < 0) b += dir.size();
    if(c < 0) c += dir.size();

    if(dir[c] == "n" && dir[b] == "e" && dir[a] == "n" ){
      d++;
    }
    if(dir[c] == "n" && dir[b] == "w" && dir[a] == "s" ){
      d++;
    }
    if(dir[c] == "s" && dir[b] == "w" && dir[a] == "s" ){
      d++;
    }
    if(dir[c] == "s" && dir[b] == "e" && dir[a] == "n" ){
      d++;
    }
    if(dir[c] == "e" && dir[b] == "s" && dir[a] == "e"){
      d++;
    }
    if(dir[c] == "e" && dir[b] == "n" && dir[a] == "w"){
      d++;
    }
    if(dir[c] == "w" && dir[b] == "n" && dir[a] == "w"){
      d++;
    }
    if(dir[c] == "w" && dir[b] == "s" && dir[a] == "e"){
      d++;
    }
  }

  cout << d << endl;

  return 0;
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;

int main(){
  std::ios::sync_with_stdio(false);

  vector < bitset<21000> > maze(21000);

  int n;

  cin >> n;

  int a, b;

  vector< pair<int, int> > pts(n+1);
  vector<string> dir;

  for (int i = 0; i <=n ; ++i)
  {
    cin >> a >> b;
    pts[i] = make_pair(a, b);

    if(i > 0){
      //east
      if(pts[i].first > pts[i-1].first){
        dir.pb("e");
      }

      //west
      else if(pts[i].first < pts[i-1].first){
        dir.pb("w");
      }

      //north
      else if(pts[i].second > pts[i-1].second){
        dir.pb("n");
      }

      //south
      else if(pts[i].second < pts[i-1].second){
        dir.pb("s");
      }
    }
  }

  ll d = 0;
  for (int i = 2; i < dir.size(); i++)
  {
    if(dir[i-2] == "n" && dir[i-1] == "e" && dir[i] == "n" ){
      d++;
    }
    if(dir[i-2] == "n" && dir[i-1] == "w" && dir[i] == "s" ){
      d++;
    }
    if(dir[i-2] == "s" && dir[i-1] == "w" && dir[i] == "s" ){
      d++;
    }
    if(dir[i-2] == "s" && dir[i-1] == "e" && dir[i] == "n" ){
      d++;
    }
    if(dir[i-2] == "e" && dir[i-1] == "s" && dir[i] == "e"){
      d++;
    }
    if(dir[i-2] == "e" && dir[i-1] == "n" && dir[i] == "w"){
      d++;
    }
    if(dir[i-2] == "w" && dir[i-1] == "n" && dir[i] == "w"){
      d++;
    }
    if(dir[i-2] == "w" && dir[i-1] == "s" && dir[i] == "e"){
      d++;
    }
  }

  cout << d << endl;

  return 0;
}


#include<iostream>

using namespace std;
struct dot{
double x;double y;}v[1004];
double Cross(dot A,dot B) { return (A.x*B.y-A.y*B.x); }
int main()
{
    int n;
    while(cin>>n)
    {
        int ans=0;
        for(int i=0;i<=n;i++)
        {
            cin>>v[i].x>>v[i].y;
        }
        int fx[1002];int tt=0;
        for(int i=2;i<=n;i++)
        {
            dot a,b;
            a.x=v[i-1].x-v[i-2].x;a.y=v[i-1].y-v[i-2].y;
            b.x=v[i].x-v[i-2].x;a.y=v[i].y-v[i-2].y;
            if(Cross(a,b)>0)fx[tt++]=1;
            else fx[tt++]=-1;
        }
        for(int i=1;i<tt;i++)
        {
            if(fx[i-1]*fx[i]<0){i++;ans++;}

        }
        //for(int i=0;i<tt;i++)cout<<fx[i]<<endl;
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>

using namespace std;
struct dot{
double x;double y;}v[1004];
double Cross(dot A,dot B) { return (A.x*B.y-A.y*B.x); }
int main()
{
    int n;
    while(cin>>n)
    {
        int ans=0;
        for(int i=0;i<=n;i++)
        {
            cin>>v[i].x>>v[i].y;
        }
        int fx[1002];int tt=0;
        for(int i=2;i<=n;i++)
        {
            dot a,b;
            a.x=v[i-2].x-v[i-1].x;a.y=v[i-2].y-v[i-1].y;
            b.x=v[i].x-v[i-2].x;b.y=v[i].y-v[i-2].y;
            if(Cross(a,b)>0)fx[tt++]=1;
            else fx[tt++]=-1;
        }
        for(int i=1;i<tt;i++)
        {
            if(fx[i-1]<0&&fx[i]>0){i++;ans++;}

        }
        //for(int i=0;i<tt;i++)cout<<fx[i]<<endl;
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>

using namespace std;
struct dot{
double x;double y;}v[1004];
double Cross(dot A,dot B) { return (A.x*B.y-A.y*B.x); }
int main()
{
    int n;
    while(cin>>n)
    {
        int ans=0;
        for(int i=0;i<=n;i++)
        {
            cin>>v[i].x>>v[i].y;
        }
        int fx[1002];int tt=0;
        for(int i=2;i<=n;i++)
        {
            dot a,b;
            a.x=v[i-2].x-v[i-1].x;a.y=v[i-2].y-v[i-1].y;
            b.x=v[i].x-v[i-2].x;b.y=v[i].y-v[i-2].y;
            if(Cross(a,b)>0)fx[tt++]=1;
            else fx[tt++]=-1;
        }
        dot a,b;
            a.x=v[n-1].x-v[0].x;a.y=v[n-1].y-v[0].y;
            b.x=v[1].x-v[n-1].x;b.y=v[1].y-v[n-1].y;
            if(Cross(a,b)>0)fx[tt]=1;
            else fx[tt]=-1;
        for(int i=0;i<=tt;i++)
        {
            if(fx[i]<0){ans++;}

        }
        //for(int i=0;i<tt;i++)cout<<fx[i]<<endl;
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<pair<int,int> >a;
    int n,ymax=-10001,ymin=10001,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        pair<int,int> b;
        cin>>b.first>>b.second;
        a.push_back(b);
        if(b.second>ymax)
        ymax=b.second;
        if(b.second<ymin)
        ymin=b.second;
    }//cout<<ymin<<ymax;
    for(int i=0;i<a.size()-1;i++)
    {
        if(a[i].second==a[i+1].second)
        {
            if(a[i].second!=ymax&&a[i].second!=ymin)
            ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<(n-4)/2;
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<pair<int,int> >a;
    int n,ymax=-10001,ymin=10001,ans=0;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        pair<int,int> b;
        cin>>b.first>>b.second;
        a.push_back(b);
        if(b.second>ymax)
        ymax=b.second;
        if(b.second<ymin)
        ymin=b.second;
    }//cout<<ymin<<ymax;
    for(int i=0;i<a.size()-1;i++)
    {
        if(a[i].second==a[i+1].second)
        {
            if(a[i].second!=ymax&&a[i].second!=ymin)
            ans++;
        }
    }
    cout<<ans;
    return 0;
}