#include <stdio.h>

#define MAX_N 100010
#define eps 1e-9

int n, d, l, r, sol;

struct punct {
	int x, y;
} A[MAX_N];

void get_points() {
	l = 1; r = 1;
	for (int i = 1; i <= n; i++) {
		if (A[i].x < A[l].x)
			l = i;
    	if (A[i].x > A[r].x)
			r = i;
	}
}

inline int prev(int i) {
	if (i == 1)
		return n;
	return i - 1;
}

inline int next(int i) {
	if (i == n)
		return 1;
	return i + 1;
}

inline int sgn(int x1, int y1, int x2, int y2, int x3, int y3) {
	long long ans = 1LL * x1 * y2 + 1LL * x2 * y3 + 1LL * x3 * y1;
 		ans = ans - 1LL * x1 * y3 - 1LL * x2 * y1 - 1LL * x3 * y2;

	if (ans > 0)
		return 1;
	if (ans < 0)
		return -1;
	return 0;
}

inline double get_dist(int Px, int Py, int x1, int y1, int x2, int y2) {
	double ans = 0;

	if (y1 == y2)
		ans = Py - y1;
	else {
		double m = 1.0 * (y2 - y1) / (x2 - x1);
		double n = y1 - m * x1;

		double Y = m * Px + n;
		ans = Y - Py;
	}

	if (ans < 0)
		ans = -ans;

	return ans;
}

inline bool equal(double p, double q) {
	double ans = p - q;
	if (ans < 0)
		ans = -ans;

	if (ans < eps)
		return true;
	return false;
}

void solve() {
	//gasesc cel mai din stanga punct si cel mai din dreapta punct
	get_points();

	//pornesc algoritmul de la punctul r
	int x = l, y = l, last = 0;

	while (!(prev(x) == next(y))) {
		int px = prev(x);
		int ny = next(y);

    	if (A[px].x < A[ny].x) {
			//vad daca segmentul x-px intersecteaza segmentul y-ny
			if (sgn(A[y].x, A[y].y, A[ny].x, A[ny].y, A[x].x, A[x].y) == -sgn(A[y].x, A[y].y, A[ny].x, A[ny].y, A[px].x, A[px].y)) {
            	//distanta la intersectie o sa fie 0
				if (last > d)
					sol++;
				last = 0;
			}

			x = px;

			double dist = get_dist(A[x].x, A[x].y, A[y].x, A[y].y, A[ny].x, A[ny].y);

			if ((last < d && d < dist) || (last > d && d > dist) || equal(dist, d))
                sol++;

			if (equal(dist, d))
                last = d;
            else
                if (dist > d)
                    last = d + 1;
                else
                    last = d - 1;
			
			if (A[ny].x == A[x].x)
				y = ny;
		}
		else {
			//vad daca segmentul y-ny intersecteaza segmentul x-px
			if (sgn(A[x].x, A[x].y, A[px].x, A[px].y, A[y].x, A[y].y) == -sgn(A[x].x, A[x].y, A[px].x, A[px].y, A[ny].x, A[ny].y)) {
            	//distanta la intersectie o sa fie 0
				if (last > d)
					sol++;
				last = 0;
			}	

			y = ny;	

			double dist = get_dist(A[y].x, A[y].y, A[x].x, A[x].y, A[px].x, A[px].y);
	
			if ((last < d && d < dist) || (last > d && d > dist) || equal(dist, d))
				sol++;

			if (equal(dist, d))
				last = d;
			else
				if (dist > d)
					last = d + 1;
				else
					last = d - 1;

			if (A[px].x == A[y].x)
				x = px;
		}
	}

	if (last > d)
		sol++;
}

int main() {
	
    freopen("monoton.in", "r", stdin);
	freopen("monoton.out", "w", stdout);
	
	scanf("%d %d", &n, &d);
	for (int i = 1; i <= n; i++)
		scanf("%d %d", &A[i].x, &A[i].y);

	solve();

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

	return 0;
}
