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

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))

#define rep(i,n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i,n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i,n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i,n) for (int i = ((int)(n)); i >= 1; i--)
#define repl(i,l,n) for (int i = (l), i##_len = (n); i < i##_len; i++)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define mp make_pair

#define has_key(m, k) (m.find(k) != m.end())

#define INF (1e9)
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const ll mod = (1000000007);

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);

    cout << b - c << endl;

    return 0;
}

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

#define MOD 2000000011
#define MAXL 26
#define MAXN 100010
#define MAXT 200
#define MAXM 101
#define PI 3.14159265359
// #define all(v) v.begin(),v.end()
#define f first
#define pb push_back
#define pii pair<int, int>
#define s second
// #define sortva(v) sort(all(v))
// #define sortvd(v) sort(v.rbegin(),v.rend())
// #define sortaa(a,n) sort(a,a+n)
// #define sortad(a,n) sort(a,a+n),reverse(a,a+n)
// #define sfi1(v) scanf("%d",&v)
// #define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
// #define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
// #define sfll1(v) scanf("%I64d",&v);
// #define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
// #define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
// #define sfstr(v) scanf("%s", v);
// #define sz(v) (int)v.size()
#define vi vector<int>
#define X real()
#define Y imag()
typedef double C;
typedef complex<C> P;
typedef long long LL;
typedef unsigned long long uLL;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int n;
pair<int, pii> store[MAXN];

int main(int argc, char const *argv[])
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin.tie(0);
	ios_base::sync_with_stdio(NULL);

	cin >> n;
	int a, p, x;
	for (int i = 0; i < n; ++i)
	{
		cin >> a >> p >> x;
		store[i] = {p, {a, x}};
	}
	sort(store, store + n);
	for (int i = 0; i < n; ++i)
	{
		if (store[i].s.f < 0.5 + (double)store[i].s.s - 1)
		{
			printf("%d\n", store[i].f);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}