#include <bits/stdc++.h>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
struct Node {
	int x, w;
	friend bool operator<(Node a, Node b) {
		return a.x < b.x;
	}
} p[N];
int xpos[N*3];
map<int, int> mp;
int tree[N*4];
void upd(int l, int r, int a, int c, int p) {
	if (l == r) {
		tree[p] = c;
		return;
	}
	int mid = (l + r) >> 1, lp = p << 1, rp = p << 1 | 1;
	if (a <= mid) upd(l, mid, a, c, lp);
	else upd(mid + 1, r, a, c, rp);
	tree[p] = max(tree[lp], tree[rp]);
}
int qry(int l, int r, int a, int b, int p) {
	if (l == a && r == b) return tree[p];
	int mid = (l + r) >> 1, lp = p << 1, rp = p << 1 | 1;
	if (b <= mid) return qry(l, mid, a, b, lp);
	else if (a > mid) return qry(mid + 1, r, a, b, rp);
	else return max(qry(l, mid, a, mid, lp), qry(mid + 1, r, mid + 1, b, rp));
}

int main() {
	int n; scanf("%d", &n);
	int m = 0;
	rep(i, n) {
		scanf("%d%d", &p[i].x, &p[i].w);
		xpos[m++] = p[i].x;
		xpos[m++] = p[i].x - p[i].w;
		xpos[m++] = p[i].x + p[i].w;
	}
	sort(p, p + n);
	sort(xpos, xpos + m);
	int idx = 0;
	rep(i, m) {
		if (mp.find(xpos[i]) == mp.end()) {
			mp[xpos[i]] = ++idx;
		}
	}
	int ans = 0;
	rep(i, n) {
		int lid = mp[p[i].x - p[i].w];
		int rid = mp[p[i].x + p[i].w];
		int mx = qry(1, idx, 1, lid, 1);
		int t = mx + 1;
		ans = max(ans, t);
		upd(1, idx, rid, t, 1);
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

using namespace std;

typedef long long INT;

#define NN 501100

INT L[NN], R[NN], arr[NN];

int B[NN];

int id[NN];

bool cmp(int u, int v){

	if(L[u]==L[v]) return R[u]<R[v];

	return L[u]<L[v];

}

int update(int u, int v){

	while(u<NN){

		B[u]=max(B[u], v);

		u+=u&-u;

	}

	return 0;

}

int calc(int u){

	int ans=0;

	while(u){

		ans=max(ans, B[u]);

		u-=u&-u;

	}

	return ans;

}

int main(){

	int N;

	INT x, w;

	cin>>N;

	int M=0;

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

		scanf("%I64d%I64d", &x, &w);

		L[i]=x-w;

		R[i]=x+w;

		id[i]=i;

		arr[M++]=L[i];

		arr[M++]=R[i];

	}

	sort(arr, arr+M);

	M=unique(arr, arr+M)-arr;

	sort(id, id+N, cmp);

	int ans=0;

	INT l, r;

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

		int k=id[i];

		l=L[k];r=R[k];

		int u=upper_bound(arr, arr+M, l)-arr;

		int v=upper_bound(arr, arr+M, r)-arr;

		int j=calc(u)+1;

		ans=max(ans, j);

		update(v, j);

	}

	cout<<ans<<endl;

	return 0;

}


#include <bits/stdc++.h>

#define NN 211111

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

pii p[NN];

int best[NN];

int find(int u, int k){

	if(u<p[0].second) return -1;

	int st=0, ed=k, md;

	while(st+1<ed){

		md=(st+ed)>>1;

		if(p[md].second>u) ed=md;

		else st=md;

	}

	if(p[ed].second<=u&&ed<k) st=ed;

	return st;

}

bool cmp(pii u, pii v){

	if(u.second!=v.second) u.second<v.second;

	return u.first<v.first;

}

int mx[NN];

int main(){

	int N, x, w, id;

	cin>>N;

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

		scanf("%d%d", &x, &w);

		p[i].first=x-w;

		p[i].second=x+w;

	}

	sort(p, p+N, cmp);

	mx[0]=0;

	id=0;

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

		if(p[id].first<=p[i].first) id=i;

		mx[i]=id;

	}

	best[0]=1;

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

		int k=find(p[i].first, i);

		if(k==-1) best[i]=1;

		else {

			k=mx[k];

			best[i]=best[k]+1;

		}

	}

	int ans=0;

	for(int i=0; i<N; i++) ans=max(ans, best[i]);

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

#define NN 611111

using namespace std;

typedef pair<int, int> pii;

int best[NN];

int arr[NN], B[NN];

pii p[NN];

int calc(int u){

	int ans=0;

	while(u){

		ans=max(ans, B[u]);

		u-=u&-u;

	}

	return ans;

}

int update(int u, int v){

	while(u<NN){

		if(B[u]<v) B[u]=v;

		u+=u&-u;

	}

	return 0;

}

int main(){

	int N, M=0;

	int x, w;

	cin>>N;

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

		scanf("%d%d", &x, &w);

		p[i]=pii(x-w, x+w);

		arr[M++]=x-w;

		arr[M++]=x+w;

	}

	sort(p, p+N);

	sort(arr, arr+M);

	M=unique(arr, arr+M)-arr;

	int ans=0;

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

		int st, ed;

		st=p[i].first;

		ed=p[i].second;

		int u=lower_bound(arr, arr+M, st)-arr+1;

		int v=lower_bound(arr, arr+M, ed)-arr+1;

		int k=calc(u);

		update(v, k+1);

	}

	cout<<calc(M)<<endl;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define NN 400111

using namespace std;

typedef pair<int,int> pii;

pii p[NN];

int B[NN], arr[NN], m;

void update(int u, int val){

	while(u<=m){

		B[u]=max(B[u], val);

		u+=u&-u;

	}

}

int calc(int u){

	int ans=0;

	while(u){

		ans=max(B[u], ans);

		u-=u&-u;

	}

	return ans;

}

int main(){

	int n, i, q, w;

	cin>>n;

	for(i=0, m=0; i<n; i++){

		cin>>p[i].x>>p[i].y;

		arr[m++]=p[i].x+p[i].y;

		arr[m++]=p[i].x-p[i].y;

	}

	sort(arr, arr+m);

	m=unique(arr, arr+m)-arr;

	sort(p, p+n);

	int mid;

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

		q=upper_bound(arr, arr+m, p[i].x-p[i].y)-arr;

		w=upper_bound(arr, arr+m, p[i].x+p[i].y)-arr;

		mid=calc(q)+1;

		update(w, mid);

	}

	cout<<calc(m)<<endl;

	return 0;

}


#include <bits/stdc++.h>

#define NN 211111

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

pii p[NN];

int best[NN];

int find(int u, int k){

	if(u<p[0].second) return -1;

	int st=0, ed=k, md;

	while(st+1<ed){

		md=(st+ed)>>1;

		if(p[md].second>u) ed=md;

		else st=md;

	}

	if(p[ed].second<=u) st=ed;

	return st;

}

int main(){

	int N, x, w;

	cin>>N;

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

		scanf("%d%d", &x, &w);

		p[i].first=x-w;

		p[i].second=x+w;

	}

	sort(p, p+N);

	best[0]=1;

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

		int k=find(p[i].first, i);

		if(k==-1) best[i]=1;

		else best[i]=best[k]+1;

	}

	int ans=0;

	for(int i=0; i<N; i++) ans=max(ans, best[i]);

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define x first

#define y second

using namespace std;

typedef long long INT;

typedef double DO;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

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;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 400010

pii p[NN];

int n;

int b[NN],ss[NN],sub[NN],x[NN],w[NN],a[NN];

void add(int u,int val){

	for(;u<=2*n;u+=u&-u) smax(b[u],val);

}

int sum(int u){

	int x=0;

	for(;u;u-=u&-u) smax(x,b[u]);

	return x;

}

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&w[i]);

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

		p[i].x=x[i];

		p[i].y=w[i];

	}

	sort(p+1,p+n+1);

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

		x[i]=p[i].x;

		w[i]=p[i].y;

	}

	int k=0;

	for(int i=1;i<=n;i++) a[++k]=x[i]+w[i];

	for(int i=1;i<=n;i++) a[++k]=x[i]-w[i];

	sort(a+1,a+k+1);

	int cnt=unique(a+1,a+k+1)-a;

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

		ss[i]=lower_bound(a+1,a+k+1,x[i]+w[i])-a;

		sub[i]=lower_bound(a+1,a+k+1,x[i]-w[i])-a;

	}

	int res=0;

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

		int ans=sum(sub[i])+1;

		add(ss[i],ans);

		smax(res,ans);

	}

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

	return 0;

}


#include <bits/stdc++.h>

#define NN 400011

#define x first

#define y second

using namespace std;

typedef pair<int, int> pii;

int arr[NN];

pii p[NN];

int nn;

int dp[NN];

int B[NN];

void update(int u, int d){

while(u<NN) {

B[u] = max(B[u], d);

u += u&-u;

}

}

int calc(int u) {

int ans=0;

while(u) {

ans = max(ans, B[u]);

u -= u & -u;

}

return ans;

}

int main(){

int n;

cin >> n;

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

scanf("%d %d", &p[i].x, &p[i].y);

arr[nn++] = p[i].x - p[i].y;

arr[nn++] = p[i].x + p[i].y;

}

sort(p+1, p+n+1);

sort(arr, arr+nn);

nn = unique(arr, arr+nn) - arr;

int ans=0;

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

int u=upper_bound(arr, arr+nn, p[i].x - p[i].y) - arr;

dp[i] = calc(u) + 1;

ans = max(ans, dp[i]);

u=upper_bound(arr, arr+nn, p[i].x + p[i].y) - arr;

update(u, dp[i]);

}

cout << ans << endl;

return 0;

}


#include <bits/stdc++.h>

#define NN 200010

using namespace std;

typedef long long INT;

typedef pair <int, int> pii;

pii p[NN];

int arr[NN*2], M;

int mx[NN*2];

int update(int u, int val){

	while(u<=M){

		mx[u]=max(mx[u], val);

		u+=u&(-u);

	}

}

int calc(int u){

	int ans=0;

	while(u){

		ans=max(ans, mx[u]);

		u-=u&(-u);

	}

	return ans;

}

int main (){

	int N;

	M=0;

	scanf("%d", &N);

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

		scanf("%d %d", &p[i].first, &p[i].second);

		arr[M++]=p[i].first-p[i].second;

		arr[M++]=p[i].first+p[i].second;

	}

	sort(p, p+N);

	sort(arr, arr+M);

	M=unique(arr, arr+M)-arr;

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

		int tmp=1;

		int id=upper_bound(arr, arr+M, p[i].first-p[i].second)-arr;

		tmp+=calc(id);

		update(upper_bound(arr, arr+M, p[i].first+p[i].second)-arr, tmp);

	}

	printf("%d\n", calc(M));

	return 0;

}


#include<bits/stdc++.h>

#define NN 400010

#define x first

#define y second

using namespace std;

typedef pair<int ,int >pii;

pii xw[NN];

int arr[NN], B[NN], m;

void update(int u){

	while(u<=m) {

		B[u]++;

		u+=u&-u;

	}

}

int calc(int u){

	int ans=0;

	while(u){

		ans+=B[u];

		u-=u&-u;

	}

	return ans;

}

int main(){

	int n,i,q,w;

	cin>>n;

	for(i=0, m=0; i<n; i++){

		scanf("%d%d", &xw[i].x, &xw[i].y);

		arr[m++]=xw[i].x+xw[i].y;

		if(xw[i].x>xw[i].y) arr[m++]=xw[i].x-xw[i].y;

	}

	sort(arr, arr+m);

	m=unique(arr, arr+m)-arr;

	sort(xw, xw+n);

	int ans=0;

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

		q=upper_bound(arr, arr+m, xw[i].x+xw[i].y)-arr;

		update(q);

		if(xw[i].x-xw[i].y>0) {

			w=upper_bound(arr, arr+m, xw[i].x-xw[i].y)-arr;

			ans=max(ans, calc(w));

		}

	}

	cout<<ans<<endl;

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i=(a); i<(b); i++)

#define x first

#define y second

const int maxn = 100010;

typedef pair < int, int > pi;

pi M[maxn];

int B[2*maxn];

int array[2*maxn];

int dp[2*maxn];

void update( int u, int val ) {

	while ( u <= maxn ) {

		B[u] = max ( B[u], val );

		u += u&(-u);

	}

}

int calc( int u) {

	int ans = 0;

	while ( u ) {

		ans = max ( ans, B[u] );

		u -= u&(-u);

	}

	return ans;

}

int main() {

	int N, cnt = 0;

	cin >> N;

	REP(i, 0, N) {

		scanf("%d%d", &M[i].x, &M[i].y);

		array[cnt++] = M[i].x+M[i].y;

	}

	sort(M, M+N);

	sort( array, array+cnt );

	cnt = unique( array, array+cnt)-array;

	int ma = 0;

	REP(i, 0, N ) {

		int xx = upper_bound( array, array+cnt,  M[i].x-M[i].y) - array;

		int yy = upper_bound( array, array+cnt,  M[i].x+M[i].y) - array;

		dp[i] = calc( xx )+1;

		ma = max ( ma, dp[i] );

		update( yy, dp[i] );

	}

	cout<<ma<<endl;

	return 0;

}


#include <bits/stdc++.h>

#define NN 211111

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

pii p[NN];

int best[NN];

int find(int u, int k){

	if(u<p[0].second) return -1;

	int st=0, ed=k, md;

	while(st+1<ed){

		md=(st+ed)>>1;

		if(p[md].second>u) ed=md;

		else st=md;

	}

	if(p[ed].second<=u&&ed<k) st=ed;

	return st;

}

bool cmp(pii u, pii v){

	if(u.second!=v.second) u.second<v.second;

	return u.first<v.first;

}

int mx[NN];

int main(){

	int N, x, w, id;

	cin>>N;

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

		scanf("%d%d", &x, &w);

		p[i].first=x-w;

		p[i].second=x+w;

	}

	sort(p, p+N, cmp);

	mx[0]=0;

	id=0;

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

		if(p[id].first<p[i].first) id=i;

		mx[i]=id;

	}

	best[0]=1;

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

		int k=find(p[i].first, i);

		if(k==-1) best[i]=1;

		else {

			k=mx[k];

			best[i]=best[k]+1;

		}

	}

	int ans=0;

	for(int i=0; i<N; i++) ans=max(ans, best[i]);

	cout<<ans<<endl;

}


#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i=(a); i<(b); i++)

#define x first

#define y second

const int maxn = 600010;

typedef pair < int, int > pi;

pi M[maxn];

int B[2*maxn];

int array[2*maxn];

int dp[2*maxn];

void update( int u, int val ) {

	while ( u <= maxn ) {

		B[u] = max ( B[u], val );

		u += u&(-u);

	}

}

int calc( int u) {

	int ans = 0;

	while ( u ) {

		ans = max ( ans, B[u] );

		u -= u&(-u);

	}

	return ans;

}

int main() {

	int N, cnt = 0;

	cin >> N;

	REP(i, 0, N) {

		scanf("%d%d", &M[i].x, &M[i].y);

		array[cnt++] = M[i].x+M[i].y;

	}

	sort(M, M+N);

	sort( array, array+cnt );

	cnt = unique( array, array+cnt)-array;

	int ma = 0;

	REP(i, 0, N ) {

		int xx = upper_bound( array, array+cnt,  M[i].x-M[i].y) - array;

		int yy = upper_bound( array, array+cnt,  M[i].x+M[i].y) - array;

		dp[i] = calc( xx )+1;

		ma = max ( ma, dp[i] );

		update( yy, dp[i] );

	}

	cout<<ma<<endl;

	return 0;

}


#include<bits/stdc++.h>

#define NN 400111

#define x first

#define y second

using namespace std;

typedef long long INT;

typedef pair<int ,int> pii;

int arr[NN], m, B[NN];

pii p[NN];

void update(int u){

	while(u<=m){

		B[u]++;

		u+=u&-u;

	}

}

int calc(int u){

	int ans=0;

	while(u){

		ans+=B[u];

		u-=u&-u;

	}

	return ans;

}

int main(){

	int n,i,z,w;

	cin>>n;

	for(i=0, m=0; i<n; i++) {

		scanf("%d%d", &p[i].x, &p[i].y);

		arr[m++]=p[i].x+p[i].y; arr[m++]=abs(p[i].x-p[i].y);

	}

	sort(arr, arr+m);

	m=unique(arr, arr+m)-arr;

	sort(p, p+n);

	int ans=0;

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

		z=upper_bound(arr, arr+m, p[i].x+p[i].y)-arr;

		w=upper_bound(arr, arr+m, abs(p[i].x-p[i].y))-arr;

		update(z);

		if(p[i].x>p[i].y) ans=max(ans, calc(w));

	}

	cout<<ans<<endl;

	return 0;

}


#include<bits/stdc++.h>

#define NN 211111

using namespace std;

int w[NN], x[NN], B[2*NN], arr[2*NN], ans=0, k, id[NN];

int update(int u, int val){

	while(u<=k){

		B[u]=max(B[u], val);

		u+=u&-u;

	}

}

int calc(int u){

	int ans=0;

	while(u){

		ans=max(ans, B[u]);

		u-=u&-u;

	}

	return ans;

}

int cmp(int u, int v){

	return x[u]<x[v];

}

int main(){

	int n,i,j;

	cin>>n;

	int ans=0;

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

		scanf("%d%d", x+i, w+i);

		arr[k++]=x[i]-w[i];

		arr[k++]=x[i]+w[i];

		id[i]=i;

	}

	sort(arr, arr+k);

	k=unique(arr, arr+k)-arr;

	sort(id, id+n, cmp);

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

		int v=upper_bound(arr, arr+k, x[id[i]]-w[id[i]])-arr;

		int tmp=calc(v)+1;

		ans=max(ans, tmp);

		int u=upper_bound(arr, arr+k, x[id[i]]+w[id[i]])-arr;

		update(u, tmp);

	}

	cout<<ans<<endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define x first

#define y second

using namespace std;

typedef long long INT;

typedef double DO;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

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;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 400010

pii p[NN];

int n;

int b[NN],ss[NN],sub[NN],x[NN],w[NN],a[NN];

void add(int u,int val){

	for(;u<=2*n;u+=u&-u) smax(b[u],val);

}

int sum(int u){

	int x=0;

	for(;u;u-=u&-u) smax(x,b[u]);

	return x;

}

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&w[i]);

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

		p[i].x=x[i];

		p[i].y=w[i];

	}

	sort(p+1,p+n+1);

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

		x[i]=p[i].x;

		w[i]=p[i].y;

	}

	int k=0;

	for(int i=1;i<=n;i++) a[++k]=x[i]+w[i];

	for(int i=1;i<=n;i++) a[++k]=x[i]-w[i];

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

		ss[i]=lower_bound(a+1,a+k+1,x[i]+w[i])-a;

		sub[i]=lower_bound(a+1,a+k+1,x[i]-w[i])-a;

	}

	int res=0;

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

		int ans=sum(sub[i])+1;

		add(ss[i],ans);

		smax(res,ans);

	}

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

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzl(x))

#define bctzl(x) (__builtin_ctzl(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

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

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

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}

template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template <class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}

template <class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2, x3), gn(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {gn(x1, x2, x3, x4), gn(x5);}

template <class T> inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

template <class T1, class T2, class T3, class T4, class T5> inline void print(T1 x1, T2 x2, T3 x3, T4 x4, T5 x5) {printsp(x1), printsp(x2), printsp(x3), printsp(x4), println(x5);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 200010

int sum[NN];

int sub[NN];

int arr[NN*3];

int x[NN];

int w[NN];

int b[NN*2];

int n;

pii pa[NN];

void update(int u,int val){

	for(;u<=2*n;u+=u&-u) smax(b[u],val);

}

int calc(int u){

	int x=0;

	for(;u;u-=u&-u) smax(x,b[u]);

	return x;

}

int main(){

#ifndef ONLINE_JUDGE

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

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

#endif

	gn(n);

	int nn=1;

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

		gn(x[i],w[i]);

		arr[nn++]=x[i]-w[i];

		arr[nn++]=x[i]+w[i];

		pa[i]=pii(x[i],w[i]);

	}

	sort(pa+1,pa+n+1);

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

		x[i]=pa[i].x;

		w[i]=pa[i].y;

	}

	sort(arr+1,arr+nn);

	nn=unique(arr+1,arr+nn)-arr;

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

		sum[i]=lower_bound(arr+1,arr+nn,x[i]+w[i])-arr;

		sub[i]=lower_bound(arr+1,arr+nn,x[i]-w[i])-arr;

	}

	int ans=0;

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

		int s=calc(sub[i])+1;

		smax(ans,s);

		update(sum[i],s);

	}

	println(ans);

}


#include <bits/stdc++.h>

#define NN 611111

using namespace std;

typedef pair<int, int> pii;

int best[NN];

int arr[NN];

pii p[NN];

int main(){

	int N, M=0;

	int x, w;

	cin>>N;

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

		scanf("%d%d", &x, &w);

		p[i]=pii(x-w, x+w);

		arr[M++]=x-w;

		arr[M++]=x+w;

	}

	sort(p, p+N);

	sort(arr, arr+M);

	M=unique(arr, arr+M)-arr;

	int ans=0;

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

		int st, ed;

		st=p[i].first;

		ed=p[i].second;

		int u=lower_bound(arr, arr+M, st)-arr+1;

		int v=lower_bound(arr, arr+M, ed)-arr+1;

		best[u]=max(best[u], best[u-1]);

		best[v]=max(best[v], best[u]+1);

		ans=max(ans, best[v]);

	}

	cout<<ans<<endl;

}


#include <bits/stdc++.h>

#define mp make_pair
#define st first
#define nd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair< ll,ll > pll;
typedef pair< int,int > pii;

const int inf = 1000000000, N = 200000, MAX = 300000;

int n, val1[N+5], val2[N+5], fen[MAX+5], dp[N+5];
pii a[N+5];
vector< pair<int, pii> > v;

int que(int x) {
	int ans = 0;

	for (; x; x -= x & -x) {
		ans = max(ans, fen[x]);
	}

	return ans;
}

void update(int x, int t) {
	for (; x <= MAX; x += x & -x) {
		fen[x] = max(fen[x], t);
	}
}

int main()
{
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i].st, &a[i].nd);
	}

	sort(a+1, a+n+1);

	for (int i = 1; i <= n; i++) {
		v.pb( mp(a[i].nd - a[i].st, mp(i, 1)) );
		v.pb( mp(-a[i].nd - a[i].st, mp(i, 2)) );
	}

	sort(v.begin(), v.end());

	for (int i = 0, j = 0; i < v.size(); i++) {
		j += !i || (v[i].st != v[i-1].st);

		if (v[i].nd.nd == 1)
			val1[v[i].nd.st] = j;
		else
			val2[v[i].nd.st] = j;
	}

	int ans = 0;

	for (int i = n; i >= 1; i--) {
		dp[i] = que(val2[i]) + 1;
		update(val1[i], dp[i]);

		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define st first
#define nd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair< ll,ll > pll;
typedef pair< int,int > pii;

const int inf = 1000000000, N = 200000, MAX = 400000;

int n, val1[N+5], val2[N+5], fen[MAX+5], dp[N+5];
pii a[N+5];
vector< pair<int, pii> > v;

int que(int x) {
	int ans = 0;

	for (; x; x -= x & -x) {
		ans = max(ans, fen[x]);
	}

	return ans;
}

void update(int x, int t) {
	for (; x <= MAX; x += x & -x) {
		fen[x] = max(fen[x], t);
	}
}

int main()
{
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i].st, &a[i].nd);
	}

	sort(a+1, a+n+1);

	for (int i = 1; i <= n; i++) {
		v.pb( mp(a[i].nd - a[i].st, mp(i, 1)) );
		v.pb( mp(-a[i].nd - a[i].st, mp(i, 2)) );
	}

	sort(v.begin(), v.end());

	for (int i = 0, j = 0; i < v.size(); i++) {
		j += !i || (v[i].st != v[i-1].st);

		if (v[i].nd.nd == 1)
			val1[v[i].nd.st] = j;
		else
			val2[v[i].nd.st] = j;
	}

	int ans = 0;

	for (int i = n; i >= 1; i--) {
		dp[i] = que(val2[i]) + 1;
		update(val1[i], dp[i]);

		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define st first
#define nd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair< ll,ll > pll;
typedef pair< int,int > pii;

const int inf = 1000000000, N = 200000, MAX = 300000;

int n, x[N+5], w[N+5], val[N+5], fen[MAX+5], dp[N+5];
vector<pii> v;

int que(int x) {
	int ans = 0;

	for (; x; x -= x & -x) {
		ans = max(ans, fen[x]);
	}

	return ans;
}

void update(int x, int t) {
	for (; x <= MAX; x += x & -x) {
		fen[x] = max(fen[x], t);
	}
}

int main()
{
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d %d", x+i, w+i);

		v.pb( mp(w[i] - x[i], i) );
	}

	sort(v.begin(), v.end());

	val[v[0].nd] = 1;
	for (int i = 1; i < n; i++) {
		val[v[i].nd] = val[v[i-1].nd] + (v[i].st != v[i-1].st);
	}

	int ans = 0;

	for (int i = n; i >= 1; i--) {
		dp[i] = que(val[i]) + 1;
		update(val[i], dp[i]);

		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define st first
#define nd second
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair< ll,ll > pll;
typedef pair< int,int > pii;

const int inf = 1000000000, N = 100000;

int main()
{

	return 0;
}


/* Author : RISHAV GOYAL */

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

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define ll pair<LL,LL>

#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 + 7)
#define MAX int(2e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

std::vector<ii> v;
int x[MAX],w[MAX],dp[MAX]={0};
int main()
{
	int n;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> w[i];
		v.pb(mp(x[i]-w[i],x[i]+w[i]));
	}
	sort(v.begin(), v.end());
	int p = n - 1;
	for(int i = n- 1; i>=0;i--){
		if(i==n-1){
			dp[i] = 1;
			continue;
		}
		if(v[i+1].S <= v[i].S){
			dp[i] = dp[i+1];
			continue;
		}
		dp[i] = dp[i+1];
		while(p>=i){
			if( v[p].F >= v[i].S ) p--;
			else {dp[i] = max(dp[i],1+dp[p+1]);break;}
		}
		p = max(p,i);

	}
	cout << dp[0] << endl;
	return 0;
}


/* Author : RISHAV GOYAL */

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

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define ll pair<LL,LL>

#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 + 7)
#define MAX int(2e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

std::vector<ii> v;
int x[MAX],w[MAX],dp[MAX]={0};
int main()
{
	int n;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> w[i];
		v.pb(mp(x[i]-w[i],x[i]+w[i]));
	}
	sort(v.begin(), v.end());
	int p = n - 1;
	for(int i = n- 1; i>=0;i--){
		if(i==n-1){
			dp[i] = 1;
			continue;
		}
		if(v[i+1].S <= v[i].S){
			dp[i] = dp[i+1];
			continue;
		}
		dp[i] = 1;
		while(p>=i){
			if( v[p].F >= v[i].S ){
				dp[i] = max(dp[i], 1 + dp[p]);
			}
			p--;
		}
		p = max(p,i);
	}
	cout << dp[0] << endl;
	return 0;
}


/* Author : RISHAV GOYAL */

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

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define ll pair<LL,LL>

#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 + 7)
#define MAX int(2e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

std::vector<ii> v;
int x[MAX],w[MAX],dp[MAX]={0};
int main()
{
	int n;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> w[i];
		v.pb(mp(x[i]-w[i],x[i]+w[i]));
	}
	sort(v.begin(), v.end());
	int p = n - 1;
	for(int i = n- 1; i>=0;i--){
		if(i==n-1){
			dp[i] = 1;
			continue;
		}
		if(v[i+1].S <= v[i].S){
			dp[i] = dp[i+1];
			continue;
		}
		dp[i] = dp[i+1];
		while(p>=i){
			if( v[p].F >= v[i].S ){
				dp[i] = max(dp[i], 1 + dp[p]);
			}
			else break;
			p--;
		}
		p = max(p,i);

	}
	cout << dp[0] << endl;
	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair < LL, LL > pii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
	return a.ss < b.ss;
}

set < LL > points;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, w;
		scanf("%d%d", &x, &w);
		line.pb(mp(x - w, x + w));
	}
	sort(line.begin(), line.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		set < LL >::iterator it = points.upper_bound(line[i].ff);
		if (it == points.end() || *it >= line[i].ss) {
			++ans;
			points.insert(line[i].ff);
			points.insert(line[i].ss);
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair < int, int > pii;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
	return a.ss < b.ss;
}

set < int > points;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, w;
		scanf("%d%d", &x, &w);
		line.pb(mp(x - w, x + w));
	}
	sort(line.begin(), line.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		set < int >::iterator it = points.lower_bound(line[i].ff);
		if (it == points.end() || *it > line[i].ss) {
			++ans;
			points.insert(line[i].ff);
			points.insert(line[i].ff);
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair < int, int > pii;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
	return a.ss < b.ss;
}

set < int > points;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, w;
		scanf("%d%d", &x, &w);
		line.pb(mp(x - w, x + w));
	}
	sort(line.begin(), line.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		set < int >::iterator it = points.upper_bound(line[i].ff);
		if (it == points.end() || *it >= line[i].ss) {
			++ans;
			points.insert(line[i].ff);
			points.insert(line[i].ss);
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair < int, int > pii;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
	return a.ss < b.ss;
}

set < int > points;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, w;
		scanf("%d%d", &x, &w);
		line.pb(mp(x - w, x + w));
	}
	sort(line.begin(), line.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		set < int >::iterator it = points.upper_bound(line[i].ff);
		if (it == points.end() || *it >= line[i].ss) {
			++ans;
			points.insert(line[i].ff);
			points.insert(line[i].ff);
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair < int, int > pii;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;
const int inf = 2e9;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
	return a.ss < b.ss;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, w;
		scanf("%d%d", &x, &w);
		line.pb(mp(x - w, x + w));
	}
	sort(line.begin(), line.end(), cmp);
	int ans = 0;
	int last = -inf;
	for (int i = 0; i < n; ++i) {
		if (last <= line[i].ff) {
			last = line[i].ss;
			++ans;
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <stdio.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair < int, int > pii;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 2e5;

int n;

vector < pii > line;
bool cmp(pii a, pii b) {
    return a.ss < b.ss;
}

set < int > points;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x, w;
        scanf("%d%d", &x, &w);
        line.pb(mp(x - w, x + w));
    }
    sort(line.begin(), line.end(), cmp);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        set < int >::iterator it = points.upper_bound(line[i].ff);
        if (it == points.end()) {
            ++ans;
            points.insert(line[i].ff);
            points.insert(line[i].ss);
        }
    }
    printf("%d\n", ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define MOD 1000000000
#define SQ 112345
#define N 1123456
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = A; I <= B; ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define PII pair<int,int>

set<int> pos[2];
multiset<int> ans[2];
multiset<int>:: iterator it1;
multiset<int>:: iterator it2;

LL arr[2];

int solve(){
    int w, h, n;
    cin>>w>>h>>n;
    char ch;
    int v, id, l, r;
    LL ans1, ans2, an;
    pos[0].insert(0);
    pos[0].insert(h);
    pos[1].insert(0);
    pos[1].insert(w);
    ans[0].insert(h);
    ans[1].insert(w);
    arr[0] = h;
    arr[1] = w;
    while(n--){

        cin>>ch;
        sd(v);
        if(ch == 'H') id = 0;
        else id = 1;
        if(pos[id].find(v) == pos[id].end()){
            it1 = pos[id].lower_bound(v);
            it2 = pos[id].upper_bound(v);
            it1--;
            l = (int)(*it1);
            r = (int)(*it2);
            ans[id].erase( ans[id].find(r - l));
            pos[id].insert(v);
            ans[id].insert(r - v);
            ans[id].insert(v - l);
            it1 = ans[id].end();
            it1--;
            arr[id] = *it1;
        }
        //cout<<arr[0]<<" "<<arr[1]<<endl;
        an = arr[1] * arr[0];
        printf("%lld\n", an);//<<endl;

    }
}

int main(){
    //freopen("in.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define MOD 1000000000
#define SQ 112345
#define N 1123456
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = A; I <= B; ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define PII pair<int,int>

multiset<int> s;
multiset<int>:: iterator it;
vector<pair<int, int> > v;
int val[N];

int query(int node, int l, int r, int x, int y){
    if(x == l && r == y){
        return val[node];
    }
    int mid= (l + r) / 2, ans = 0;
    if(x <= mid){
        ans = query(2 * node, l, mid, x, min(mid, y));
    }
    if(y > mid){
        ans = max(ans, query(2 * node + 1, mid + 1, r, max(mid + 1, x), y));
    }
    return ans;
}

int update(int node, int l, int r, int p, int v){
    if(l == r && r == p){
        val[node] = v;
        return 0;
    }
    int mid= (l + r) / 2, ans = 0;
    if(p <= mid){
        update(2 * node, l, mid, p, v);
    }
    else{
        update(2 * node + 1, mid + 1, r, p, v);
    }
    val[node] = max(val[2 * node], val[2 * node + 1]);
}
vector<int> vec;
int solve(){
    int n, ans, x, y, j, i, ma;
    cin>>n;
    REP(i, 1, n){
        sd(x); sd(y);
        v.PB(MP(x, y));
    }
    sort(v.begin(), v.end());
    REP(i, 0, n - 1){
        vec.PB(v[i].F + v[i].S);
        vec.PB(v[i].F - v[i].S);

    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    int q, tmp, id;
    ans = 0;
    REP(i, 0, n - 1){
        q = v[i].F - v[i].S;
        id = (int)(lower_bound(vec.begin(), vec.end(), q) - vec.begin()) + 1;
        tmp = query(1, 1, vec.size(), 1, id);
        ans = max(ans, tmp + 1);
        q = v[i].F + v[i].S;
        update(1, 1, vec.size(), (int)(lower_bound(vec.begin(), vec.end(), q) - vec.begin()) + 1, tmp + 1);
    }
    cout<<ans<<endl;
}

int main(){
    //freopen("in.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define MOD 1000000000
#define SQ 112345
#define N 1123456
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = A; I <= B; ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define PII pair<int,int>

multiset<int> s;
multiset<int>:: iterator it;
vector<pair<int, int> > v;
int solve(){
    int n, ans, x, y, j, i, ma;
    cin>>n;
    REP(i, 1, n){
        sd(x); sd(y);
        v.PB(MP(x, y));
    }
    sort(v.begin(), v.end());
    j = 0;
    ans = 0;
    REP(i, 0, n - 1){
        if(i == j) {
            s.insert(v[i].F + v[i].S);
            j++;
        }
        if(j > n) break;
        it = s.end();
        it--;
        ma = *it;
        while(v[j].F - v[j].S >= ma){
            s.insert(v[i].F + v[i].S);
            it = s.end();
            it--;
            ma = *it;
            j++;
        }
        s.erase(s.find(v[i].F + v[i].S));
        ans = max(ans, j - i);
    }
    cout<<ans<<endl;
}

int main(){
    //freopen("in.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define MOD 1000000000
#define SQ 112345
#define N 1123456
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = A; I <= B; ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define PII pair<int,int>

multiset<int> s;
multiset<int>:: iterator it;
vector<pair<int, int> > v;
int solve(){
    int n, ans, x, y, j, i, ma;
    cin>>n;
    REP(i, 1, n){
        sd(x); sd(y);
        v.PB(MP(x, y));
    }
    sort(v.begin(), v.end());
    j = 0;
    ans = 0;
    REP(i, 0, n - 1){
        if(i == j) {
            s.insert(v[i].F + v[i].S);
            j++;
        }
        if(j > n) break;
        it = s.end();
        it--;
        ma = *it;
        while(v[j].F - v[j].S >= ma){
            s.insert(v[j].F + v[j].S);
            it = s.end();
            it--;
            ma = *it;
            j++;
        }
        s.erase(s.find(v[i].F + v[i].S));
        ans = max(ans, j - i);
    }
    cout<<ans<<endl;
}

int main(){
    //freopen("in.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define MOD 1000000000
#define SQ 112345
#define N 1123456
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = A; I <= B; ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define PII pair<int,int>

multiset<int> s;
multiset<int>:: iterator it;
vector<pair<int, int> > v;
int solve(){
    int n, ans, x, y, j, i, ma;
    cin>>n;
    REP(i, 1, n){
        sd(x); sd(y);
        v.PB(MP(x, y));
    }
    sort(v.begin(), v.end());
    j = 0;
    ans = 0;
    REP(i, 0, n - 1){
        if(i == j) {
            s.insert(v[i].F + v[i].S);
            j++;
        }
        if(j > n) break;
        it = s.end();
        it--;
        ma = *it;
        while(j < n && v[j].F - v[j].S >= ma){
            s.insert(v[j].F + v[j].S);
            it = s.end();
            it--;
            ma = *it;
            j++;
        }
        s.erase(s.find(v[i].F + v[i].S));
        ans = max(ans, j - i);
    }
    cout<<ans<<endl;
}

int main(){
    //freopen("in.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    if(l==r)
    {
        tree[root].ma=0;
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int query(int root,int l,int r)
{
    if(l==tree[root].l&&r==tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return query(root*2,l,mid)+query(root*2+1,mid+1,r);
}
void update(int root,int p,int k)
{
    if(p==tree[root].l&&p==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
        int k=query(1,1,p);
        k++;
        p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
        update(1,p,k);
        }
    }
    int jg=query(1,1,n)+1;
    printf("%d\n",jg);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    if(l==r)
    {
        tree[root].ma=0;
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int query(int root,int l,int r)
{
    if(l<=tree[root].l&&r>=tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return query(root*2,l,mid)+query(root*2+1,mid+1,r);
}
void update(int root,int p,int k)
{
    if(tree[root].l==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
            int k=query(1,1,p);
            k++;
            p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
            update(1,p,k);
        }
    }
    printf("%d\n",query(1,1,n)+1);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    tree[root].ma=0;
    if(l==r)
    {
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
}
int query(int root,int l,int r)
{
    if(l==tree[root].l&&r==tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return max(query(root*2,l,mid),query(root*2+1,mid+1,r));
}
void update(int root,int p,int k)
{
    if(tree[root].l==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
            int k=query(1,1,p);
            k++;
            p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
            update(1,p,k);
        }
    }
    printf("%d\n",query(1,1,n)+1);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    if(l==r)
    {
        tree[root].ma=0;
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int query(int root,int l,int r)
{
    if(l==tree[root].l&&r==tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return query(root*2,l,mid)+query(root*2+1,mid+1,r);
}
void update(int root,int p,int k)
{
    if(tree[root].l==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
            int k=query(1,1,p);
            k++;
            p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
            update(1,p,k);
        }
    }
    printf("%d\n",query(1,1,n)+1);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    tree[root].ma=0;
    if(l==r)
    {
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
}
int query(int root,int l,int r)
{
    if(l==tree[root].l&&r==tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return query(root*2,l,mid)+query(root*2+1,mid+1,r);
}
void update(int root,int p,int k)
{
    if(tree[root].l==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
            int k=query(1,1,p);
            k++;
            p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
            update(1,p,k);
        }
    }
    printf("%d\n",query(1,1,n)+1);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[800100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    tree[root].ma=0;
    if(l==r)
    {
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
}
int query(int root,int l,int r)
{
    if(l<=tree[root].l&&r>=tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    int s=0;
    if(l<=mid)  s=max(query(root*2,l,r),s);
    if(r>mid)   s=max(query(root*2+1,l,r),s);
    return s;
}
void update(int root,int p,int k)
{
    if(tree[root].l==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
            int k=query(1,1,p);
            k++;
            p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
            update(1,p,k);
        }
    }
    printf("%d\n",query(1,1,n)+1);
}


//
//  main.cpp
//  cf
//
//  Created by 刘鑫伟 on 15/3/18.
//  Copyright (c) 2015年 刘鑫伟. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[200100];
struct data
{
    int l,r,ma;
}tree[400100];
struct data2
{
    int x,w;
}b[200100];
int cmp(data2 a,data2 b)
{
    return a.x<b.x;
}
void build(int root,int l,int r)
{
    tree[root].l=l,tree[root].r=r;
    if(l==r)
    {
        tree[root].ma=0;
        return ;
    }
    int mid=(l+r)/2;
    build(root*2,l,mid);
    build(root*2+1,mid+1,r);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int query(int root,int l,int r)
{
    if(l==tree[root].l&&r==tree[root].r)
    {
        return tree[root].ma;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(r<=mid)  return query(root*2,l,r);
    else if(l>mid)  return query(root*2+1,l,r);
    else return query(root*2,l,mid)+query(root*2+1,mid+1,r);
}
void update(int root,int p,int k)
{
    if(p==tree[root].l&&p==tree[root].r)
    {
         tree[root].ma=max(tree[root].ma,k);
        return ;
    }
    int mid=(tree[root].l+tree[root].r)/2;
    if(p<=mid)   update(root*2,p,k);
    else  update(root*2+1,p,k);
    tree[root].ma=max(tree[root*2].ma,tree[root*2+1].ma);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&b[i].x,&b[i].w);
        a[i]=b[i].x+b[i].w;
    }
    sort(a+1,a+1+n);
    build(1,1,n);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1, a+1+n,b[i].x-b[i].w)-a;
        if(a[p]!=b[i].x-b[i].w) p--;
        if(p>0)
        {
        int k=query(1,1,p);
        k++;
        p=lower_bound(a+1, a+1+n,b[i].x+b[i].w)-a;
        update(1,p,k);
        }
    }
    int jg=query(1,1,n)+1;
    printf("%d\n",jg);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 200005;

int n;
int dp[ N ];
struct str {
    int x, w;
    str( ) { }
}M[ N ];

bool cmp( str a, str b ) {
    return a.x < b.x;
}

void load( ) {
    scanf( "%d", &n );
    for( int i = 0; i < n; i++ ) {
        scanf( "%d%d", &M[ i ].x, &M[ i ].w );
    }
}

void solve( ) {
    sort( M, M + n, cmp );
    dp[ 0 ] = 1;
    int sol = 1;
    int curr_max = 0;
    int ptr = 0;
    for( int i = 1; i < n; i++ ) {
        while( ptr < i && M[ i ].x - M[ ptr ].x >= M[ i ].w + M[ ptr ].w ) curr_max = max( curr_max, dp[ ptr ] ), ptr++;
        dp[ i ] = curr_max + 1;
        sol = max( sol, dp[ i ] );
    }
    printf( "%d\n", sol );
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 200005;

int n;
pii P[ N ];
int dp[ N ];

void load( ) {
    scanf( "%d", &n );
    for( int i = 0; i < n; i++ ) scanf( "%d%d", &P[ i ].x, &P[ i ].y );
}

void solve( ) {
    sort( P, P + n );
    int ptr = 0;
    int curr_max = 0;
    dp[ 0 ] = 1;
    int ans = 1;
    for( int i = 1; i < n; i++ ) {
        while( ptr < i && P[ i ].x - P[ ptr ].x >= P[ i ].y + P[ ptr ].y ) curr_max = max( curr_max, dp[ ptr ] ), ptr++;
        dp[ i ] = curr_max + 1;
        ans = max( ans, dp[ i ] );
    }
    printf( "%d\n", ans );
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 200005;

int n;
pii P[ N ];
int dp[ N ];

void load( ) {
    scanf( "%d", &n );
    for( int i = 0; i < n; i++ ) scanf( "%d%d", &P[ i ].x, &P[ i ].y );
}

void solve( ) {
    sort( P, P + n );
    int ptr = 0;
    int curr_max = -1;
    int ans = 0;
    for( int i = 0; i < n; i++ ) {
        while( ptr < i && P[ i ].x - P[ ptr ].x >= P[ i ].y + P[ ptr ].y ) curr_max = max( curr_max, dp[ ptr ] ), ptr++;
        if( curr_max != -1 ) {
            dp[ i ] = curr_max + 1;
            ans = max( ans, dp[ i ] );
        }
    }
    printf( "%d\n", ans );
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 200005;

int n;
int dp[ N ];
struct str {
    int x, w;
    str( ) { }
}M[ N ];

bool cmp( str a, str b ) {
    return a.x < b.x;
}

void load( ) {
    scanf( "%d", &n );
    for( int i = 0; i < n; i++ ) {
        scanf( "%d%d", &M[ i ].x, &M[ i ].w );
    }
}

vector< int > V;

int get( int x ) {
    return lower_bound( V.begin( ), V.end( ), x ) - V.begin( ) + 1;
}

struct fenwick {
    int tree[ N * 2 ];
    int n;
    fenwick( ) {
        memset( tree, 0, sizeof( tree ) );
        n = 400004;
    }
    void add( int x, int val ) { for( ; x < n; x += x & -x ) tree[ x ] = max( tree[ x ], val ); }
    int get( int x ) { int ans = 0; for( ; x > 0; x -= x & -x ) ans = max( ans, tree[ x ] ); return ans; }
}F;

void solve( ) {
    sort( M, M + n, cmp );
    for( int i = 0; i < n; i++ ) V.pb( M[ i ].x + M[ i ].w ), V.pb( M[ i ].x - M[ i ].w );
    sort( V.begin( ), V.end( ) );
    V.erase( unique( V.begin( ), V.end( ) ), V.end( ) );
    dp[ 0 ] = 1;
    int sol = 1;
    int curr_max = 0;
    F.add( get( M[ 0 ].x + M[ 0 ].w ), 1 );
    for( int i = 1; i < n; i++ ) {
        int curr = F.get( get( M[ i ].x - M[ i ].w ) );
        dp[ i ] = curr + 1;
        sol = max( sol, dp[ i ] );
        F.add( get( M[ i ].x + M[ i ].w ), dp[ i ] );
    }
    printf( "%d\n", sol );
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 200005;

int n;
pii P[ N ];
int dp[ N ];

void load( ) {
    scanf( "%d", &n );
    for( int i = 0; i < n; i++ ) scanf( "%d%d", &P[ i ].x, &P[ i ].y );
}

void solve( ) {
    sort( P, P + n );
    int ptr = 0;
    int curr_max = -1;
    int ans = 0;
    for( int i = 0; i < n; i++ ) {
        while( ptr < i && P[ i ].x - P[ ptr ].x >= P[ i ].y + P[ ptr ].y ) curr_max = max( curr_max, dp[ ptr ] ), ptr++;
        if( curr_max != -1 ) {
            dp[ i ] = max( curr_max, 1 ) + 1;
            ans = max( ans, dp[ i ] );
        }
    }
    printf( "%d\n", ans );
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


/* DHUOJ solution #362394 @ 2018-08-13 20:29:18.225 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll cg=1e9;
const int maxn=2e5+100;
struct Node
{
    int x,f;
    int op;
};
vector<Node> nodes;
map<ll,int> dp;
bool cmp(Node a,Node b)
{
    return a.x<b.x;
}
int main()
{
    int n,x,w,pre=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&w);
        Node temp1,temp2;
        temp1.x=x-w,temp1.f=-1;
        temp2.x=x+w,temp2.f=1,temp2.op=temp1.x;
        nodes.push_back(temp1),nodes.push_back(temp2);
    }
    sort(nodes.begin(),nodes.end(),cmp);
    dp[nodes[0].x+cg]=0;
    for(int i=1;i<nodes.size();i++)
    {
            dp[nodes[i].x+cg]=pre;
            if(nodes[i].f==1)
            dp[nodes[i].x+cg]=max(dp[nodes[i].x+cg],dp[nodes[i].op+cg]+1);
        pre=dp[nodes[i].x+cg];
    }
    printf("%d\n",dp[nodes[nodes.size()-1].x+cg]);
    return 0;
}


/* DHUOJ solution #362345 @ 2018-08-13 20:34:29.170 */

#include <iostream>
#include <stdio.h>
#include <cstring>
#include<algorithm>
using namespace std;
const int NUM=2e5+10;
struct node
{
    int index,q;
    bool operator <(const node &a)const
    {
        return index+q<a.index+a.q;
    }
}no[NUM];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d%d",&no[i].index,&no[i].q);
    sort(no,no+n);
    int ans=1,last=0;
    for (int i=1;i<n;i++)
    {
        if (no[i].index-no[i].q>=no[last].index+no[last].q)
        {
            last=i;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


/* DHUOJ solution #362405 @ 2018-08-14 01:37:23.545 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362394 @ 2018-08-14 00:42:16.463 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll cg=1e9;
const int maxn=2e5+100;
struct Node
{
    int x,f;
    int op;
};
vector<Node> nodes;
map<ll,int> dp;
bool cmp(Node a,Node b)
{
    return a.x<b.x;
}
int main()
{
    int n,x,w,pre=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&w);
        Node temp1,temp2;
        temp1.x=x-w,temp1.f=-1;
        temp2.x=x+w,temp2.f=1,temp2.op=temp1.x;
        nodes.push_back(temp1),nodes.push_back(temp2);
    }
    sort(nodes.begin(),nodes.end(),cmp);
    dp[nodes[0].x+cg]=0;
    for(int i=1;i<nodes.size();i++)
    {
            dp[nodes[i].x+cg]=pre;
            if(nodes[i].f==1)
            dp[nodes[i].x+cg]=max(dp[nodes[i].x+cg],dp[nodes[i].op+cg]+1);
        pre=dp[nodes[i].x+cg];
    }
    printf("%d\n",dp[nodes[nodes.size()-1].x+cg]);
    return 0;
}


/* DHUOJ solution #362405 @ 2018-08-14 09:37:51.732 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362405 @ 2018-08-13 21:36:50.251 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362394 @ 2018-08-13 23:32:30.611 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll cg=1e9;
const int maxn=2e5+100;
struct Node
{
    int x,f;
    int op;
};
vector<Node> nodes;
map<ll,int> dp;
bool cmp(Node a,Node b)
{
    return a.x<b.x;
}
int main()
{
    int n,x,w,pre=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&w);
        Node temp1,temp2;
        temp1.x=x-w,temp1.f=-1;
        temp2.x=x+w,temp2.f=1,temp2.op=temp1.x;
        nodes.push_back(temp1),nodes.push_back(temp2);
    }
    sort(nodes.begin(),nodes.end(),cmp);
    dp[nodes[0].x+cg]=0;
    for(int i=1;i<nodes.size();i++)
    {
            dp[nodes[i].x+cg]=pre;
            if(nodes[i].f==1)
            dp[nodes[i].x+cg]=max(dp[nodes[i].x+cg],dp[nodes[i].op+cg]+1);
        pre=dp[nodes[i].x+cg];
    }
    printf("%d\n",dp[nodes[nodes.size()-1].x+cg]);
    return 0;
}


/* DHUOJ solution #362345 @ 2018-08-13 21:21:17.723 */

#include <iostream>
#include <stdio.h>
#include <cstring>
#include<algorithm>
using namespace std;
const int NUM=2e5+10;
struct node
{
    int index,q;
    bool operator <(const node &a)const
    {
        return index+q<a.index+a.q;
    }
}no[NUM];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d%d",&no[i].index,&no[i].q);
    sort(no,no+n);
    int ans=1,last=0;
    for (int i=1;i<n;i++)
    {
        if (no[i].index-no[i].q>=no[last].index+no[last].q)
        {
            last=i;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


/* DHUOJ solution #362405 @ 2018-08-13 23:22:05.414 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362405 @ 2018-08-14 01:57:25.095 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362405 @ 2018-08-14 01:17:21.273 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362405 @ 2018-08-14 00:47:26.256 */

#include <bits/stdc++.h>
#define ll int
using namespace std;
pair<ll,ll>p[200005];
int main()
{
	ll n,i,w,x,s=0,l=-(1<<31);
	cin>>n;
	for(i=0;i<n;i++)
		cin>>x>>w,p[i]=make_pair(x+w,x-w);
	sort(p,p+n);
	for(i=0;i<n;i++)
		if(p[i].second>=l)
			l=p[i].first,s++;
	cout<<s;
}


/* DHUOJ solution #362409 @ 2018-08-13 23:27:18.977 */

#include <bits/stdc++.h>
using namespace std;
pair<int,int> a[200005];
int main()
{
    int n,x,y;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        a[i].first=x+y;
        a[i].second=x-y;
    }
    sort(a,a+n);
    int l=1<<31;
    int ans=0;
    for(int i=0;i<n;i++)
        if(a[i].second>=l)
            l=a[i].first,ans++;
        cout<<ans<<endl;
}
/*
4 3 4
H 2
V 2
V 3
V 1
*/


//
//  A.cpp
//  CODE
//
//  Created by Vikas Yadav on 29/10/14.
//  Copyright (c) 2014 Vikas Yadav. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iterator>
#include <memory.h>
#include <cassert>

using namespace std;

#define pll pair < long long,long long >
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define F first
#define S second

#define MOD 1000000007
#define INF 999999
#define N 212345
#define VAL 20000
#define LN 25

long long n;
vector < pair < long long , long long > > arr;
map < long long , long long > key;
set < long long > dad;
long long dp[N];
long long bit[N];

void update(long long index,long long val){
    if(index<=0)    return;
    while(index<N){
        bit[index] = max(bit[index],val);
        index += (index & (-index));
    }
}

long long query(long long index){
    if(index<=0)        return 0;
    long long ans = bit[index];
    while(index>0){
        ans = max(ans,bit[index]);
        index -= (index & (-index));
    }
    return ans;
}

int main(){
    scanf("%I64d", &n);
    long long x,y,ans,tim = 0;
    for(int a=0;a<n;a++){
        scanf("%I64d%I64d", &x, &y);
        arr.pb(mp(x,y));
        dad.insert(x+y);
        dad.insert(x-y);
    }
    sort(arr.begin(),arr.end());
    while(!dad.empty()){
        key[*dad.begin()] = ++tim;
        dad.erase(dad.begin());
    }
    for(int a=0;a<n;a++){
        dp[a] = query(key[arr[a].F-arr[a].S])+1;
        update(key[arr[a].F+arr[a].S], dp[a]);
    }
    ans = dp[0];
    for(int a=0;a<n;a++){
        ans = max(ans,dp[a]);
    }
    printf("%I64d\n", ans);
    return 0;
}


//
//  A.cpp
//  CODE
//
//  Created by Vikas Yadav on 29/10/14.
//  Copyright (c) 2014 Vikas Yadav. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iterator>
#include <memory.h>
#include <cassert>

using namespace std;

#define pll pair < long long,long long >
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define F first
#define S second

#define MOD 1000000007
#define INF 999999
#define N 212345
#define VAL 20000
#define LN 25

long long n;
vector < pair < long long , long long > > arr;
long long dp[N];
long long bit[N];

void update(long long index,long long val){
    if(index<=0)    return;
    while(index<N){
        bit[index] = max(bit[index],val);
        index += (index & (-index));
    }
}

long long query(long long index){
    if(index<=0)        return 0;
    long long ans = bit[index];
    while(index>0){
        ans = max(ans,bit[index]);
        index -= (index & (-index));
    }
    return ans;
}

int main(){
    scanf("%I64d", &n);
    long long x,y,ans;
    for(int a=0;a<n;a++){
        scanf("%I64d%I64d", &x, &y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    for(int a=0;a<n;a++){
        dp[a] = query(arr[a].F-arr[a].S)+1;
        update(arr[a].F+arr[a].S, dp[a]);
    }
    ans = dp[0];
    for(int a=0;a<n;a++){
        ans = max(ans,dp[a]);
    }
    printf("%I64d\n", ans);
    return 0;
}


//
//  A.cpp
//  CODE
//
//  Created by Vikas Yadav on 29/10/14.
//  Copyright (c) 2014 Vikas Yadav. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iterator>
#include <memory.h>
#include <cassert>

using namespace std;

#define pll pair < long long,long long >
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define F first
#define S second

#define MOD 1000000007
#define INF 999999
#define N 212345
#define VAL 20000
#define LN 25

long long n;
vector < pair < long long , long long > > arr;
long long dp[N];

long long func(int x){
    if(x==n)        return 0;
    if(dp[x]!=0)        return dp[x];
    dp[x] = 1;
    for(int i=x+1;i<n;i++){
        if(arr[i].F-arr[x].F < arr[i].S+arr[x].S)       continue;
        dp[x] = max(dp[x],func(i)+1);
    }
    return dp[x];
}

int main(){
    scanf("%I64d", &n);
    long long x,y,ans;
    for(int a=0;a<n;a++){
        scanf("%I64d%I64d", &x, &y);
        arr.pb(mp(x,y));
    }
    sort(arr.begin(),arr.end());
    func(0);
    ans = dp[0];
    for(int a=0;a<n;a++){
        ans = max(ans,dp[a]);
    }
    printf("%I64d\n", ans);
    return 0;
}


//
//  A.cpp
//  CODE
//
//  Created by Vikas Yadav on 29/10/14.
//  Copyright (c) 2014 Vikas Yadav. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iterator>
#include <memory.h>
#include <cassert>

using namespace std;

#define pll pair < long long,long long >
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define F first
#define S second

#define MOD 1000000007
#define INF 999999
#define N 412345
#define VAL 20000
#define LN 25

long long n;
vector < pair < long long , long long > > arr;
map < long long , long long > key;
set < long long > dad;
long long dp[N];
long long bit[N];

void update(long long index,long long val){
    if(index<=0)    return;
    while(index<N){
        bit[index] = max(bit[index],val);
        index += (index & (-index));
    }
}

long long query(long long index){
    if(index<=0)        return 0;
    long long ans = bit[index];
    while(index>0){
        ans = max(ans,bit[index]);
        index -= (index & (-index));
    }
    return ans;
}

int main(){
    scanf("%I64d", &n);
    long long x,y,ans,tim = 0;
    for(int a=0;a<n;a++){
        scanf("%I64d%I64d", &x, &y);
        arr.pb(mp(x,y));
        dad.insert(x+y);
        dad.insert(x-y);
    }
    sort(arr.begin(),arr.end());
    while(!dad.empty()){
        key[*dad.begin()] = ++tim;
        dad.erase(dad.begin());
    }
    for(int a=0;a<n;a++){
        dp[a] = query(key[arr[a].F-arr[a].S])+1;
        update(key[arr[a].F+arr[a].S], dp[a]);
    }
    ans = dp[0];
    for(int a=0;a<n;a++){
        ans = max(ans,dp[a]);
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define lsone(x) (x&(-x))
using namespace std;

vector<pair<int,int> > val;
int n;

struct bit{

    int b[200010];
    bit(){
        memset(b,0,sizeof b);
    }

    int query(int pos){
        int maximo = -1;
        for(int i = pos;i>0;i-=lsone(i))
            maximo = max(maximo,b[i]);
        return maximo;
    }

    void update(int pos,int val){
        for(int i = pos;i<=n;i+=lsone(i)){
            b[i]= max(b[i],val);
        }
    }

};

int main(){

    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        val.push_back(make_pair(a+b,a-b));
    }
    sort(val.begin(), val.end());
    bit bt;
    for(int i = 1;i<n;i++){
        int lo = 0, hi = i-1;
        while(lo<hi){
            int mid = (lo + hi + 1)/2;
            if(val[i].second<val[mid].first){
                hi = mid-1;
            }else{
                lo = mid;
            }
        }
        int valor = -1;
        if(val[i].second>=val[lo].first)
            valor = bt.query(lo+1);
        bt.update(i+1,valor+1);
    }
    printf("%d\n",bt.query(n) + 1);

    return 0;
}


#include <bits/stdc++.h>
#define lsone(x) (x&(-x))
using namespace std;

long long v[200000][2];
vector<pair<long long,int> > val;
int n;

struct bit{

    int b[200010];
    bit(){
        memset(b,0,sizeof b);
    }

    int query(int pos){
        int maximo = -1;
        for(int i = pos;i>0;i-=lsone(i))
            maximo = max(maximo,b[i]);
        return maximo;
    }

    void update(int pos){
        int val = query(pos);
        val++;
        for(int i = pos;i<=n;i+=lsone(i)){
            b[i]= max(b[i],val);
        }
    }

};

int main(){

    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        scanf("%lld %lld",&v[i][0],&v[i][1]);
        val.push_back(make_pair(v[i][0] + v[i][1],v[i][0] - v[i][1]));
    }
    sort(val.begin(), val.end());
    bit bt;

    for(int i = 0;i<n;i++){
        int lo = 0, hi = i-1;
        while(lo<hi){
            int mid = (lo + hi + 1)/2;
            if(val[i].second<val[mid].first){
                hi = mid-1;
            }else{
                lo = mid;
            }
        }
        if(val[i].second>=val[lo].first)
            bt.update(lo+1);
    }
    cout<<bt.query(n) + 1<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int n, a[200], res;

int main() {
    cin >> n;
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    for (int i = 0, j; i < 2 * n; i += 2) {
        for (j = i + 1; a[i] != a[j]; j++);
        for (int k = j; k > i + 1; k--)
            a[k] = a[k - 1], res++;
    }
    cout << res;
}


#include <iostream>

using namespace std;

int main() {
    int n, res = 0, a[100];
    cin >> n;
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    for (int i = 0, j; i < 2 * n; i += 2) {
        for (j = i + 1; a[i] != a[j]; j++);
        for (int k = j; k > i + 1; k--)
            a[k] = a[k - 1], res++;
    }
    cout << res;
}


#include <iostream>

using namespace std;

int n, a[100];
long long res;

int main() {
    cin >> n;
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    for (int i = 0, j; i < 2 * n; i += 2) {
        for (j = i + 1; a[i] != a[j]; j++);
        for (int k = j; k > i + 1; k--)
            a[k] = a[k - 1], res++;
    }
    cout << res;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n=10;
    scanf("%i",&n);
    int niz[2*n];
    for(int i=0;i<2*n;i++)
    {
        scanf("%i",&niz[i]);
    }
    /*for(int i=0;i<n;i++)
    {
        niz[i]=i+1;
    }
    for(int i=0;i<n;i++)
    {
        niz[i+n]=n-i;
    }*/
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    bool test=true;
    int cnt=0;
    while(test)
    {
        int visited[n+1]={};
        int udaljenost=0;
        int koja_strana[2*n];
        bool sortiran=true;
        for(int i=0;i<2*n;i++)
        {
            if(visited[niz[i]]==0)
            {
                koja_strana[i]=1;
                visited[niz[i]]=i+1;
                if(niz[i+1]!=niz[i])
                {
                    sortiran=false;
                }
            }
            else
            {
                koja_strana[i]=2;
                //printf("Udaljenost od %i: %i\n",niz[i],i-visited[niz[i]]);
                udaljenost+=i-visited[niz[i]];
            }
        }
        if(sortiran)
        {
            break;
        }
        //cnt++;
        int koji=-1;
        for(int i=0;i<2*n;i++)
        {
            //printf("%i ",niz[i]);
            if(koja_strana[i]==1)
            {
                if(niz[i+1]!=niz[i])
                {
                    if(koja_strana[i+1]==2)
                    {
                        koji=i;
                        break;
                    }
                }
            }
            else
            {
                if(niz[i-1]!=niz[i])
                {
                    if(koja_strana[i-1]==1)
                    {
                        koji=i;
                        break;
                    }
                }
            }
        }
        //printf("\n");
        if(koji!=-1)
        {
            cnt++;
            if(koja_strana[koji]==1)
        {
            swap(niz[koji],niz[koji+1]);
        }
        else
        {
            swap(niz[koji],niz[koji-1]);
        }
        }
        else
        {
            cnt+=udaljenost;
            break;
        }

        //printf("%i %i\n",(*it).first,(*it).second);
    }
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    printf("%i\n",cnt);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    scanf("%i",&n);
    int niz[2*n];
    for(int i=0;i<2*n;i++)
    {
        scanf("%i",&niz[i]);
    }
    bool test=true;
    int cnt=0;
    while(test)
    {
        int visited[n+1]={};
        int koja_strana[2*n];
        bool sortiran=true;
        for(int i=0;i<2*n;i++)
        {
            if(visited[niz[i]]==0)
            {
                koja_strana[i]=1;
                visited[niz[i]]=1;
                if(niz[i+1]!=niz[i])
                {
                    sortiran=false;
                }
            }
            else
            {
                koja_strana[i]=2;
            }
        }
        if(sortiran)
        {
            break;
        }
        cnt++;
        int koji;
        for(int i=0;i<2*n;i++)
        {
            //printf("%i ",niz[i]);
            if(koja_strana[i]==1)
            {
                if(niz[i+1]!=niz[i])
                {
                    if(koja_strana[i+1]==2)
                    {
                        koji=i;
                        break;
                    }
                    else
                    {
                        koji=i;
                    }
                }
            }
            else
            {
                if(niz[i-1]!=niz[i])
                {
                    if(koja_strana[i-1]==1)
                    {
                        koji=i;
                        break;
                    }
                    else
                    {
                        koji=i;
                    }
                }
            }
        }
        //printf("\n");
        if(koja_strana[koji]==1)
        {
            swap(niz[koji],niz[koji+1]);
        }
        else
        {
            swap(niz[koji],niz[koji-1]);
        }
        //printf("%i %i\n",(*it).first,(*it).second);
    }
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    printf("%i\n",cnt);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n=10;
    scanf("%i",&n);
    int niz[2*n];
    for(int i=0;i<2*n;i++)
    {
        scanf("%i",&niz[i]);
    }
    /*for(int i=0;i<n;i++)
    {
        niz[i]=i+1;
    }
    for(int i=0;i<n;i++)
    {
        niz[i+n]=n-i;
    }*/
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    bool test=true;
    int cnt=0;
    while(test)
    {
        int visited[n+1]={};
        int udaljenost=0;
        int koja_strana[2*n];
        bool sortiran=true;
        for(int i=0;i<2*n;i++)
        {
            if(visited[niz[i]]==0)
            {
                koja_strana[i]=1;
                visited[niz[i]]=i+1;
                if(niz[i+1]!=niz[i])
                {
                    sortiran=false;
                }
            }
            else
            {
                koja_strana[i]=2;
                //printf("Udaljenost od %i: %i\n",niz[i],i-visited[niz[i]]);
                udaljenost+=i-visited[niz[i]];
            }
        }
        if(sortiran)
        {
            break;
        }
        //cnt++;
        int koji=-1;
        for(int i=0;i<2*n;i++)
        {
            //printf("%i ",niz[i]);
            if(koja_strana[i]==1)
            {
                if(niz[i+1]!=niz[i])
                {
                    if(koja_strana[i+1]==2)
                    {
                        koji=i;
                        break;
                    }
                }
            }
            else
            {
                if(niz[i-1]!=niz[i])
                {
                    if(koja_strana[i-1]==1)
                    {
                        koji=i;
                        break;
                    }
                }
            }
        }
        //printf("\n");
        if(koji!=-1)
        {
            cnt++;
            if(koja_strana[koji]==1)
            {
                swap(niz[koji],niz[koji+1]);
            }
            else
            {
                swap(niz[koji],niz[koji-1]);
            }
        }
        else
        {
            int gde;
            int solved_end=0;
            for(int i=2*n-1;i>0;i--)
            {
                if(niz[i]==niz[i-1])
                {
                    solved_end+=2;
                    i--;
                }
                else
                {
                    break;
                }
            }
            for(int i=0;i<2*n-2;i++)
            {
                if(niz[i]==niz[i+1]&&koja_strana[i+2]==2)
                {
                    gde=i+1;
                }
            }
            //printf("gde:%i,%i %i\n",gde,solved_end,(2*n-gde-1-solved_end));
            int sta=niz[gde];
            cnt+=2*(2*n-gde-1-solved_end);
            for(int i=gde-1;i<2*n-2-solved_end;i++)
            {
                niz[i]=niz[i+2];
            }
            niz[2*n-2-solved_end]=sta;
            niz[2*n-1-solved_end]=sta;
            //niz[2*n-2]=sta;
        }
        //printf("%i %i\n",(*it).first,(*it).second);
    }
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    printf("%i\n",cnt);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    scanf("%i",&n);
    int niz[2*n];
    for(int i=0;i<2*n;i++)
    {
        scanf("%i",&niz[i]);
    }
    bool test=true;
    int cnt=0;
    while(test)
    {
        int visited[n+1]={};
        int koja_strana[2*n];
        bool sortiran=true;
        for(int i=0;i<2*n;i++)
        {
            if(visited[niz[i]]==0)
            {
                koja_strana[i]=1;
                visited[niz[i]]=1;
                if(niz[i+1]!=niz[i])
                {
                    sortiran=false;
                }
            }
            else
            {
                koja_strana[i]=2;
            }
        }
        if(sortiran)
        {
            break;
        }
        cnt++;
        set<pair<int,int> > swaps;
        for(int i=0;i<2*n;i++)
        {
            //printf("%i ",niz[i]);
            if(koja_strana[i]==1)
            {
                if(niz[i+1]!=niz[i])
                {
                    if(koja_strana[i+1]==2)
                    {
                        swaps.insert(make_pair(1,i));
                    }
                    else
                    {
                        swaps.insert(make_pair(0,i));
                    }
                }
            }
            else
            {
                if(niz[i-1]!=niz[i])
                {
                    if(koja_strana[i-1]==1)
                    {
                        swaps.insert(make_pair(1,i));
                    }
                    else
                    {
                        swaps.insert(make_pair(0,i));
                    }
                }
            }
        }
        //printf("\n");
        set<pair<int,int> >::iterator it;
        it=swaps.end();
        it--;
        int koji=(*it).second;
        if(koja_strana[koji]==1)
        {
            swap(niz[koji],niz[koji+1]);
        }
        else
        {
            swap(niz[koji],niz[koji-1]);
        }
        //printf("%i %i\n",(*it).first,(*it).second);
    }
    /*for(int i=0;i<2*n;i++)
        {
            printf("%i ",niz[i]);
        }
        printf("\n");*/
    printf("%i\n",cnt);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)

using namespace std;

const ll INF=(1ll<<62)-1;
const int inf=(1<<30)-1;

int res;
 int v[2000];
    int main()
    {
        ios;
        int n;

        cin>>n;

        for(int i=1;i<=n+n;i++)
        {
            cin>>v[i];
        }
        for(int i=1;i<=n+n;i+=2)
        {
            int id=i+1;
            while(v[id] != v[i])id++;

            for(int j=id;j>=i+2;j--)
            {
                swap(v[j],v[j-1]);
                res++;
            }
        }
        cout<<res<<endl;

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)

using namespace std;

const ll INF=(1ll<<62)-1;
const int inf=(1<<30)-1;

int res;
    int main()
    {
        ios;
        int n;
        cin>>n;
        vector<int>v(n+n);
        for(int i=1;i<=n+n;i++)
        {
            cin>>v[i];
        }
        for(int i=1;i<=n+n;i+=2)
        {
            int id=i+1;
            while(v[id] != v[i])id++;

            for(int j=id;j>i+2;j--)
            {
                swap(v[j],v[j-1]);
                res++;
            }
        }
        cout<<res<<endl;

    }


#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=105;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,ans;int a[N];
int main(){
	n=read();rep(i,1,n<<1)a[i]=read();
	rep(i,1,n<<1){
		if(i&1!=1)continue;
		int k=a[i];
		rep(j,i+1,n<<1)if(k==a[j]){
			ans+=j-i-1;
			rpd(t,j,i+1)swap(a[t],a[t-1]);
			break;
		}
	}
	printf("%d\n",ans);return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=105;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,ans;int a[N<<1];
int main(){
	n=read();rep(i,1,n<<1)a[i]=read();
	rep(i,1,n<<1){
		if(i&1!=1)continue;
		int k=a[i];
		rep(j,i+1,n<<1)if(k==a[j]){
			ans+=j-i-1;
			rpd(t,j,i+1)swap(a[t],a[t-1]);
			break;
		}
	}
	printf("%d\n",ans);return 0;
}


#include <iostream>

using namespace std;
long long v[205];
bool f[105];
int main()
{
    long long n,pasi=0,cnt;
    cin>>n;
    for(long long i=1;i<=2*n;i++){
        cin>>v[i];
    }
    for(long long i=1;i<=2*n;i++){
        if(f[v[i]]==0){
            f[v[i]]=0;
            if(v[i]==v[i+1]){
                continue;
            }
            cnt=0;
            for(long long j=i+1;j<=2*n;j++)
                if(v[j]==v[i]){
                    pasi+=cnt;
                    v[j]=0;
                    break;
                }
                else{
                    if(v[j]!=0)
                        cnt++;
                }
        }
    }
    cout<<pasi;
    return 0;
}


#include <iostream>

using namespace std;
long long v[205];
bool f[105];
int main()
{
    long long n,pasi=0,cnt;
    cin>>n;
    for(long long i=1;i<=2*n;i++){
        cin>>v[i];
    }
    for(long long i=1;i<=2*n;i++){
        if(f[v[i]]==0){
            f[v[i]]=1;
            if(v[i]==v[i+1]){
                continue;
            }
            cnt=0;
            for(long long j=i+1;j<=2*n;j++)
                if(v[j]==v[i]){
                    pasi+=cnt;
                    v[j]=0;
                    break;
                }
                else{
                    if(v[j]!=0)
                        cnt++;
                }
        }
    }
    cout<<pasi;
    return 0;
}


#include <iostream>

using namespace std;
long long v[205];
bool f[105];
int main()
{
    long long n,pasi=0,cnt;
    cin>>n;
    for(long long i=1;i<=2*n;i++){
        cin>>v[i];
    }
    for(long long i=1;i<=2*n;i++){
        if(f[v[i]]==0 and v[i]!=0){
            f[v[i]]=1;
            if(v[i]==v[i+1]){
                continue;
            }
            cnt=0;
            for(long long j=i+1;j<=2*n;j++)
                if(v[j]==v[i]){
                    pasi+=cnt;
                    v[j]=0;
                    break;
                }
                else{
                    if(v[j]!=0)
                        cnt++;
                }
        }
    }
    cout<<pasi;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i = a; i < n; i++)
#define FORR(i,a,n) for(int i = a; i >n;i--)
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x), ri(y)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define db(x) printf("%d\n",x)
typedef long long ll;

int main()
{
	int n;
	int a[200];
	int es[200];
	int lr[200];
	ri(n);
	memset(es,0,sizeof(es));
	FOR(i,0,2*n)
	{
		ri(a[i]);
	}
	FOR(i,0,2*n)
	{
		if(es[a[i]]==0)
		{
			lr[i]=0;
			es[a[i]]=1;
		}
		else
			lr[i]=1;
	}
	int flag,c,k;
	int ans =0;

	FOR(i,0,2*n-1)
	{
		if(a[i]!=a[i+1])
		{
			flag = 1;
			c = 0;
			FOR(j,i+1,2*n)
			{
				if(a[i]==a[j])
				{
					k = j;
				}
				else
				{
					if(lr[i]==0)
						c--;
					else
						c++;
				}
			}
			if(c<0)
			{
				while(k!=i+1)
				{
					swap(a[k],a[k-1]);
					k--;
					ans++;
				}
			}
			else
			{
				int l = i;
				while(l!=k-1)
				{
					swap(a[l],a[l+1]);
					l++;
					ans++;
				}
			}
			i--;
		}
		else
			i++;
	}
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i = a; i < n; i++)
#define FORR(i,a,n) for(int i = a; i >n;i--)
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x), ri(y)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define db(x) printf("%d\n",x)
typedef long long ll;

int main()
{
	int n;
	int a[200];
	int e[200];
	int es[200];
	int lr[200],lre[200];
	ri(n);
	memset(es,0,sizeof(es));
	FOR(i,0,2*n)
	{
		ri(a[i]);
		e[i]=a[i];
	}
	FOR(i,0,2*n)
	{
		if(es[a[i]]==0)
		{
			lr[i]=0;
			lre[i]=0;
			es[a[i]]=1;
		}
		else{
			lr[i]=1;
			lre[i]=0;
		}
	}
	int flag,c,k;
	int ans1 =0;
	FOR(i,0,2*n-1)
	{
		if(a[i]!=a[i+1])
		{
			c = 0;
			FOR(j,i+1,2*n)
			{
				if(a[i]==a[j])
				{
					k = j;
					break;
				}
				else
				{
					if(lr[j]==0)
						c--;
					else
						c++;
				}
			}
			if(c<0)
			{
				while(k!=i+1)
				{
					swap(a[k],a[k-1]);
					swap(lr[k],lr[k-1]);
					k--;
					ans1++;
				}
			}
			else
			{
				int l = i;
				while(l!=k-1)
				{
					swap(a[l],a[l+1]);
					swap(lr[l],lr[l+1]);
					l++;
					ans1++;
				}
			}
			i--;
		}
		else
			i++;
	}
	int ans2 = 0;
	FORR(i,2*n-1,0)
	{
		if(e[i]!=e[i-1])
		{
			c = 0;
			FORR(j,i-1,-1)
			{
				if(e[i]==e[j])
				{
					k = j;
					break;
				}
				else
				{
					if(lre[j]==0)
						c--;
					else
						c++;
				}
			}
			if(c<0)
			{
				int l = i;
				while(l!=k+1)
				{
					swap(e[l],e[l-1]);
					swap(lre[l],lre[l-1]);
					l--;
					ans2++;
				}

			}
			else
			{
				while(k!=i-1)
				{
					swap(e[k],e[k+1]);
					swap(lre[k],lre[k+1]);
					k++;
					ans2++;
				}
			}
			i++;
		}
		else
			i--;
	}
	printf("%d\n",min(ans1,ans2));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i = a; i < n; i++)
#define FORR(i,a,n) for(int i = a; i >n;i--)
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x), ri(y)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define db(x) printf("%d\n",x)
typedef long long ll;

int main()
{
	int n;
	int a[200],c[200];
	ri(n);
	FOR(i,0,2*n)
	{
		ri(a[i]);
		c[i]=a[i];
	}
	int k;
	int vis[100];
	memset(vis,0,sizeof(vis));
	int m1 = 0, m2 = 0;
	FOR(i, 0, 2*n)
	{
		if(!vis[a[i]])
		{
			vis[a[i]]=1;
			FOR(j,i+1,2*n)
			{
				if(a[j]==a[i])
				{
					k = j;
					break;
				}
			}
			while(k!=i+1)
			{
				swap(a[k],a[k-1]);
				m1++;
				k--;
			}
		}
	}
	memset(vis,0,sizeof(vis));
	FORR(i, 2*n-1, -1)
	{
		if(!vis[c[i]])
		{
			vis[c[i]]=1;
			FORR(j,i-1,-1)
			{
				if(c[j]==c[i])
				{
					k = j;
					break;
				}
			}
			while(k!=i-1)
			{
				swap(c[k],c[k+1]);
				m2++;
				k++;
			}
		}
	}
	printf("%d\n",min(m1,m2));
	return 0;
}


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

int main()
{
    int n,i,j,k,l,cnt=0,c=0;
    cin>>n;
    n*=2;
    int a[n+9];
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i+=2)
    {
        c = -1;
        for(j=i+1; j<n; j++)
        {
            if(a[i]==a[j])
            {
                c= j;
                break;
            }
        }
        while(i<c-1)
        {
            swap(a[c],a[c-1]);
            //for(k=0; k<n; k++)
                //cout<<a[k]<<" ";
            //cout<<endl;
            --c;
            ++cnt;
        }
    }
    cout<<cnt<<endl;

}


#include<bits/stdc++.h>
using namespace std;
long long  arr[100000];

long long  nn[3909000];

//string   a,b,u,l;int h;vector<int>lk;

vector<pair<int,int>> v;
typedef long long ll;
int main()
{
ll a; cin>>a;

	for (int i = 0; i < a*2; i++) {
		cin>>nn[i];
	}
	int ans=0;
for (int i = 0; i < a*2; i++) {
		if(arr[nn[i]]){continue;}
		int x=nn[i+1];int l=i+1;

		while(x!=nn[i]){
            ans++;
            l++;
            x=nn[l];
		}
		arr[nn[i]]=1;
	}

cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long  arr[100000];

long long  nn[3909000];

//string   a,b,u,l;int h;vector<int>lk;

vector<pair<int,int>> v;
typedef long long ll;
int main()
{
ll a; cin>>a;

	for (int i = 0; i < a*2; i++) {
		cin>>nn[i];
	}
	int ans=0;
for (int i = 0; i < (a*2); i++) {
		if(arr[nn[i]]){continue;}
		int x=nn[i+1];int l=i+1;

		while(x!=nn[i]){
            ans+=!arr[nn[l]];
            l++;
            x=nn[l];
		}
		arr[nn[i]]=1;}

cout<<ans;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[205];
int main(){
	int ans=0;
	cin>>n;
	for(int i=1; i<=2*n; i++)	cin>>a[i];
	for(int i=1; i<=2*n; i++){
		int j=-1;
		for(int x=i+1; x<=2*n; x++)
			if(a[x]==a[i]){
				j = x;
				break;
			}
		if(j==-1)	continue;
		j--;
		for(; j!=i; j--)
			swap(a[j], a[j+1]), ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[105];
int main(){
	int ans=0;
	cin>>n;
	for(int i=1; i<=2*n; i++)	cin>>a[i];
	for(int i=1; i<=2*n; i++){
		int j=-1;
		for(int x=i+1; x<=2*n; x++)
			if(a[x]==a[i]){
				j = x;
				break;
			}
		if(j==-1)	continue;
		j--;
		for(; j!=i; j--)
			swap(a[j], a[j+1]), ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int a[210];
int k,m,n;
int main(){
	n=read();
	for(register int i=1;i<=n*2;i++)a[i]=read();
	int ans=0;
	for(register int i=1;i<=n*2;i+=2){
		for(register int j=i+1;j<=n*2;j++){
			if(a[i]==a[j]){
				for(register int k=j-1;k>=i+1;k--){
					swap(a[k],a[k+1]);
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int a[210];
int k,m,n;
int main(){
	n=read();
	for(register int i=1;i<=n*2;i++)a[i]=read();
	int ans=0;
	for(register int i=1;i<=n*2;i+=2){
		for(register int j=i+1;j<=n*2;j++){
			if(a[i]==a[j]){
				for(register int k=i+1;k<j;k++){
					swap(a[k],a[k+1]);
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}