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

#define ll long long
#define rep(i, n) for(int i=0; i<(int)(n); i++)

double A, B;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> A >> B;
    cout << A*B/100 << endl;
}

                              ////JAI SHREE RAM////
#include <iostream>
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const long long int INF = (long long)1e15;
const long long int mod = 1e9+7;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define sd second
#define ft first

bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    //return (a.sd>=b.sd);
    return abs(a.ft)+abs(a.sd) < abs(b.ft)+abs(b.sd);
}
void prime(vector<ll>&v,ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if(n/i!=i) v.pb(n/i);
        }
    }
    v.pb(n);
}
int binPow(int a, int n)
{
    int res=1;
    while(n)
    {
        if(n&1)
            res=(1ll*res*a)%mod;
        a=(1ll*a*a)%mod;
        n>>=1;
    }
    return res;
}
int C(int n,int k,ll fact[],ll inv[])
{
    if(k>n) return 0;
    int res = (1ll*fact[n]*inv[k])%mod;
    res=(1ll*res*inv[n-k])%mod;
    //cout<<res<<endl;
    return res;
}

void solve()
{
    double a,b;cin>>a>>b;
    double ans = (a*b)/100;
    cout<<setprecision(12)<<ans<<endl;
}
int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<typename T>
istream &operator>>(istream &in, vector<T> &x) {
    for (auto &i : x)
        in >> i;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &x) {
    for (auto &i : x) {
        out << i << " ";
    }
    return out;
}

template<typename T, typename D>
istream &operator>>(istream &in, pair<T, D> &x) {
    in >> x.first >> x.second;
    return in;
}

template<typename T, typename D>
ostream &operator<<(ostream &out, const pair<T, D> &x) {
    out << x.first << " " << x.second;
    return out;
}

struct LogOutput {
    template<typename T>
    LogOutput &operator<<(T x) {
#ifdef Dmitry07
        cout << x;
#endif
        return *this;
    }
} dout;

typedef long long ll;
typedef unsigned long long ull;
typedef double dl;

#define nl '\n'
#define elif else if
#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vpi vector<pair<int, int>>
#define eb emplace_back
#define pb push_back
// #define MOD1(x, m) ((x) % m + ((x) < 0  && ((x % m) != 0) ? m : 0))
#define mod(x, m) (((x) % (m) + (m)) % (m))
#define vi vector<int>
#define pi pair<int, int>
#define ti tupMXle<int, int, int>
#define minq(x, y) x = min((x), (y))
#define maxq(x, y) x = max((x), (y))
#define forn(i, n) for (int i = 0; i < (n); ++i)

const ll INFL = 1e15;  // 9187201950435737471;
const ll nINFL = -9187201950435737472;
const int INF = 1e9 + 10;  // 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const dl PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

inline void IO() {
#ifdef Dmitry07
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

const int MAXN = 1e5 + 10;
const int MAXE = 1e5 + 10;
const int MOD = 1e9 + 9;
const double EPS = 1e-9;
const int W = 1e6 + 100;
const int K = 1000 + 1;

// #define int ll

vpi g[MAXN];
int col[MAXN], colOfParEdge[MAXN], par[MAXN], n;
char used[MAXN];

void dfs(int v) {
    used[v] = 1;
    if (v) {
        if (col[par[v]] == colOfParEdge[v]) {
            col[v] = col[par[v]] % n + 1;
        } else {
            col[v] = colOfParEdge[v];
        }
    }
    for (auto[to, c] : g[v]) {
        if (!used[to]) {
            colOfParEdge[to] = c;
            par[to] = v;
            dfs(to);
        }
    }
}

void Solve() {
    int m;
    cin >> n >> m;
    forn (i, m) {
        int v, u, c;
        cin >> v >> u >> c;
        v--;
        u--;
        g[v].pb({u, c});
        g[u].pb({v, c});
    }
    col[0] = 1;
    dfs(0);
    forn (i, n) {
        cout << col[i] << nl;
    }
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    int startTime = clock();
    while (t--) {
        Solve();
    }
    int endTime = clock();
    dout << '\n' << "Time: " << (endTime - startTime) / 1000.0;
    return 0;
}

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

string N;
int K;

ll pat[202020][17];

const ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>K;
	int mask=0;

	FOR(i,N.size()) {
		char c=N[i];
		if(c>='A'&&c<='F') y=10+c-'A';
		else y=(c-'0');

		//初
		if(i) {
			pat[i+1][1]+=15;
		}
		//less
		FOR(j,y) {
			if(i==0&&j==0) continue;
			int mask2=mask|(1<<j);
			x=__builtin_popcount(mask2);
			pat[i+1][x]++;
		}
		//any
		FOR(x,17) {
			(pat[i+1][x]+=pat[i][x]*x)%=mo;
			if(x<16) (pat[i+1][x+1]+=pat[i][x]*(16-x))%=mo;
		}

		mask|=(1<<y);
	}

	ll ret=pat[N.size()][K];
	if(__builtin_popcount(mask)==K) ret++;

	cout<<ret%mo<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi>
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF 1e18
#define NINF -1e17
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
bool cmp(ll a,ll b)
{
	return (a>b);
}
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
#ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("error.in", "w", stderr);
    freopen("output.in", "w", stdout);
#endif
	ll n;
	cin>>n;
	vpii v;
	f(i,n)
	{
		ll x,y;
		cin>>x>>y;
		v.pb({x,y});
	}
	ll ans=0;
	f(i,n-1)
	{
		fo(j,i+1,n-1)
		{
			ll x1=v[i].F;
			ll y1=v[i].S;
			ll x2=v[j].F;
			ll y2=v[j].S;
			if(x1==x2)
			{
				continue;
			}
			double z=(((y2-y1)*1.00)/(x2-x1));
			//cout<<z<<endl;
			if(z>=-1 && z<=1)
			{
				ans++;
			}
		}
	}
	cout<<ans;
    return 0;
}

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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

inline void work() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int dx = x[j] - x[i];
            int dy = y[j] - y[i];
            if (dx == 0) {
                continue;
            }
            if (dx < 0) {
                dx = -dx;
                dy = -dy;
            }
            if ((dy >= 0 && dy <= dx) || (dy < 0 && dy >= -dx)) {
                ++ans;
            }
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);

ll random2(){
    return (1ll << 31ll)*eng()+eng();
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

int const base = 550000;

int DP[101][base+1] = {0};

void solve(){
    DP[0][0] = 1;
    int ma = 0;
    for(int i = 0; i < n; i++){
        int ma2 = 0;
        for(int sum = 0; sum <= ma; sum++){
            for(int a = 0; a <= k; a++){
                DP[i+1][sum+a*(i+1)] += DP[i][sum];
                if(DP[i+1][sum+a*(i+1)] >= m)DP[i+1][sum+a*(i+1)] -= m;
            }
        }
        ma = ma+k*(i+1);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("fhc.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k >> m;
    solve();
    rep(x,1,n+1){
        ll temp = 0;
        //cerr << "x: " << x << "\n";
        rep(sum,0,base+1){
            ll thing = (ll(DP[x-1][sum])*ll(DP[n-x][sum]))%m;
            thing *= ll(k+1);
            thing %= m;
            temp += thing;
            if(temp >= m)temp -= m;
         //  if(sum < 10) cerr << ll(DP[x-1][sum]) << " " << DP[n-x][sum] << " " << k << "\n";
        }
        cout << (temp+m-1)%m << "\n";
    }

    return 0;
}


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

using ll = long long;

ll A, B, C;

long double memo[101][101][101];

long double f(int a, int b, int c){
    if(memo[a][b][c] != 0)return memo[a][b][c];
    if(a == 100 || b == 100 || c == 100){
        return 0;
    }
    return memo[a][b][c] = (1.0 * a / (a + b + c)) * (f(a + 1, b, c) + 1) + (1.0 * b / (a + b + c))* (f(a, b + 1, c) + 1) + (1.0 * c / (a + b + c))* (f(a, b, c + 1) + 1);
}

void solve(){
    cout<<setprecision(20)<<f(A, B, C);
}

int main(){
    scanf("%lld",&A);

    scanf("%lld",&B);
    scanf("%lld",&C);
    solve();
    return 0;
}

//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<ctime>
//#include<algorithm>//next_permutation
#define rep(i,n) for (ll i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

int main(){
  long double a,b,c; cin >> a >> b >> c; dec(15);

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

  vector<vector<vector<long double>>> dp(110,vector<vector<long double>>(110,vector<long double>(110)));

  dp[a][b][c] = 1.0;

  for(ll i=0; i < 100; i++){
    for(ll j=0; j < 100; j++){
      for(ll k=1; k < 100; k++){

        long double now = dp[i][j][k];

        long double di[] = {1.0,0,0};
        long double dj[] = {0,1.0,0};
        long double dk[] = {0,0,1.0};

        rep(l,3){
          dp[i+di[l]][j+dj[l]][k+dk[l]] +=
          (i*di[l] + j*dj[l] + k*dk[l])/((long double)(i+j+k))*now;
        }

      }
    }
  }

  long double ans = 0;

  for(ll i=0; i < 100; i++){
    for(ll j=0; j < 100; j++){
      ans += dp[100][i][j]*(100+i+j-a-b-c);
      ans += dp[i][100][j]*(100+i+j-a-b-c);
      ans += dp[i][j][100]*(100+i+j-a-b-c);
    }
  }

  cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Node;
vector<Node> V;
struct Node {
  vector<int> nbr;
  bool vst = false;
  int val = 0;
  void dfs() {
    vst = true;
    val++;
    for(int x : nbr) if(!V[x].vst) V[x].dfs();
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  REP(i, N) V.emplace_back();
  REP(i, N) {
    string S;
    cin >> S;
    REP(j, N) {
      if(S[j] == '1') {
        V[i].nbr.push_back(j);
      }
    }
  }
  double ans = 0;
  REP(i, N) {
    REP(j, N) V[j].vst = false;
    V[i].dfs();
  }
  REP(i, N) ans += 1.0 / V[i].val;
  cout << fixed << setprecision(10) << ans << "\n";

}

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

using ll = long long;
using Vi = std::vector<int>;
using Vl = std::vector<ll>;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

constexpr int I_INF = std::numeric_limits<int>::max();
constexpr ll L_INF = std::numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <ostream& os = std::cout>
class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        auto operator()(const Args&... args) const -> decltype((os << ... << std::declval<Args>()), void()) { print(args...); }
        template <typename T>
        auto pvec(const T& vec, size_t sz) const -> decltype(os << std::declval<decltype(std::declval<T>()[0])>(), void()) {
            for (size_t i = 0; i < sz; i++)
                os << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T>
        auto pmat(const T& mat, size_t h, size_t w) -> decltype(os << std::declval<decltype(std::declval<T>()[0][0])>(), void()) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++)
                    os << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { os << term; }
        void print_rest() const { os << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { os << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { os << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints<> prints;
Prints<std::cerr> prints_err;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int N;
    cin >> N;
    static bool reachable[100][100] = {};
    for (ll i = 0; i < N; i++) {
        reachable[i][i] = true;
    }
    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        for (ll j = 0; j < N; j++) {
            if (s[j] == '1') reachable[i][j] = true;
        }
    }
    for (ll k = 0; k < N; k++) {
        for (ll i = 0; i < N; i++) {
            for (ll j = 0; j < N; j++) {
                reachable[i][j] |= reachable[i][k] & reachable[k][j];
            }
        }
    }
    double ans = 0.0;
    for (ll i = 0; i < N; i++) {
        ll cnt = 0;
        for (ll j = 0; j < N; j++) {
            if (reachable[j][i]) ++cnt;
        }
        ans += 1.0 / cnt;
    }
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    std::ifstream ifs("./in_out/input.txt");
    std::cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    std::ofstream ofs("./in_out/output.txt");
    std::cout.rdbuf(ofs.rdbuf());
#endif
    std::cout << std::setprecision(18) << std::fixed;
    solve();
    std::cout << std::flush;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template<class T> void chmax(T& a, T b){
    if(a < b){
        a = b;

    }
}
template<class T> bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
int main()
{
    int n;
    cin >> n;

    vector<int>a(n);
    vector<int>b(n);

    rep(i,n)cin >> a[i] >> b[i];

    const int inf = 1e6;

    int ans = inf;
    rep(i,n){
        rep(j,n){
            int time;
            if(i == j)time = a[i] + b[i];
            else{
                time = max(a[i],b[j]);
            }

            chmin(ans,time);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int solve(int a) {
  return a;
}

int main() {
  int N;
  int A[1010];
  int B[1010];
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  int ia = 0;
  int ib = 0;
  int ib_second = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < A[ia]) {
      ia = i;
    }
    if (B[i] < B[ib]) {
      ib_second = ib;
      ib = i;
    }
  }

  if (ia == ib) {
    cout << min( A[ia] + B[ib], max(A[ia], B[ib_second]) ) << endl;
  } else if(ia == ib_second) {
    cout << min( max(A[ia], B[ib]), A[ia] + B[ib_second] ) << endl;
  } else {
    cout << min( max(A[ia], B[ib]), max(A[ia], B[ib_second]) ) << endl;
  }
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
template<typename T>
struct segment_tree {
    int n;
    vector<T> segtree;
    function<T(const T&,const T&)> join;
    T base = T();
    segment_tree(int n, function<T(const T&,const T&)> join, T base = T()) : n(n), join(join), base(base){
        segtree.resize(n << 1, base);
    }
    void build() {
        for (int i = n - 1; i > 0; --i) {
            segtree[i] = join(segtree[(i << 1)], segtree[(i << 1) | 1]);
        }
    }
    segment_tree(vector<T> seq, function<T(const T&,const T&)> join, T base = T()) : n(seq.size()), join(join), base(base){
        segtree.resize(n << 1, base);
        for (int i = 0; i < n; i++) {
            segtree[n + i] = seq[i];
        }
        build();
    }
    void calc(int pos){
        pos >>= 1;
        while (pos) {
            segtree[pos] = join(segtree[pos << 1], segtree[(pos << 1) | 1]);
            pos >>= 1;
        }
    }
    void set(int pos, T val){
        pos+=n;
        segtree[pos] = val;
        calc(pos);
    }
    void increment(int pos, T val){
        pos+=n;
        segtree[pos] = join(segtree[pos], val);
        calc(pos);
    }
    T query(int l, int r) {
        T ansl = base;
        T ansr = base;
        l += n;
        r += n + 1;
        while (l < r) {
            if (l & 1) {
                ansl = join(ansl, segtree[l++]);
            }
            if (r & 1) {
                ansr = join(segtree[--r], ansr);
            }
            l >>= 1;
            r >>= 1;
        }
        return join(ansl, ansr);
    }
};
void solve(){
    int n,q;
    cin>>n>>q;
    vector<int> seq(n);
    cin>>seq;
    segment_tree<int> st(seq, [&](int x,int y){
        return x^y;
    }, 0);
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t == 1){
            int idx,y;
            cin>>idx>>y;
            --idx;
            st.increment(idx, y);
        }
        else{
            int l,r;
            cin>>l>>r;
            --l;--r;
            cout<<st.query(l,r)<<"\n";
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
const int INF=101010001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int main(){
    string s;
    cin>>s;
    cout<<s.at(1)<<s.at(2)<<s.at(0)<<endl;
}

// A - Rotate
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define rep2(i, s, n) for(int i=(s); i<(int)(n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    string s;
    cin >> s;
    s += s[0];
    string ans = s.substr(1, 3);
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, f, t) for(int i = f; i <= t; i ++)
#define urep(i, f, t) for(int i = f; i >= t; i --)
#define pb push_back
#define pq priority_queue
#define addr(v) v.begin(), v.end()
#define qstream std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = 1e18 + 7;

ll gcd(ll a, ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v, interal;

	rep(i, 1, k) {
		int tmp;
		cin >> tmp;
		v.pb(tmp);
	}
	sort(addr(v));
	if((v.size() && *v.begin() > 1))interal.pb(*v.begin() - 1);
	rep(i, 1, (int)v.size() - 1) {
		if(v[i] - v[i - 1] - 1) interal.pb(v[i] - v[i - 1] - 1);
	}
	if(v.size() && n - *v.rbegin() > 1) interal.pb(n - *v.rbegin());
	ll cnt = 0, ans;
//	if(v.size()) {
//		ans = *interal.begin();
//		cout << ans << endl;
//		rep(i, 1, (int)interal.size() - 1) {
//			ans = gcd(ans, interal[i]);
//			cout << interal[i] << " " << ans << endl;
//		}
//		rep(i, 0, (int)interal.size() - 1) {
//			cnt += interal[i] / ans;
//		}
//	}
//	//cout << ans << endl;
	if(interal.size()) {
		sort(addr(interal));
		ans = *interal.begin();
		rep(i, 0, (int)interal.size() - 1) {
			cnt += (interal[i] % ans) ? interal[i] / ans + 1 : interal[i] / ans;
		}
	}
	if(!k) cnt = 1;
	cout << cnt << endl;
	return 0;
}

#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int n = input();

  vector< pair<pair<int, int>, int>> vs;
  vector< pair<int, int> > ps;
  range(i, 0, n) {
    pair<int, int> p;
    cin >> p;
    ps.emplace_back(p);
    vs.emplace_back(p, i);
  }

  vector< int > idxs;
  whole(sort, vs);
  idxs.emplace_back(vs[0].second);
  idxs.emplace_back(vs[1].second);
  idxs.emplace_back(vs[n-1].second);
  idxs.emplace_back(vs[n-2].second);

  whole(sort, vs, [](auto &a, auto &b) { return a.first.second < b.first.second; });
  idxs.emplace_back(vs[0].second);
  idxs.emplace_back(vs[1].second);
  idxs.emplace_back(vs[n-1].second);
  idxs.emplace_back(vs[n-2].second);

  whole(sort, idxs);
  idxs.erase(whole(unique, idxs), idxs.end());

  vector< i64 > ds;
  for (auto &i : idxs) for (auto &j : idxs) {
    if (i >= j) continue;
    i64 d = max(abs(ps[i].first - ps[j].first), abs(ps[i].second - ps[j].second));
    ds.emplace_back(d);
  }

  rwhole(sort, ds);
  cout << ds[1] << endl;
}

signed main() {
  solve();
}


/*
problem : arc 120 D
algorithm :stack
created : Programmer_juruo
*/

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

#define int long long
#define N 2000005
#define M 2005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define se second
#define fi first
#define y1 juruo
#define mp make_pair
#define pb push_back
#define arr vector<int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

typedef pair <int, int> pii;
typedef priority_queue <int> pq;
typedef long long ll;

const int inf = 0x3f3f3f3f;
const int p = 107;
const int P = 100007;
const int Mod = 1e9+7;

int n, m;
int b[N];
vector <pii> ar;
void work() {
	cin >> n;
	vector <int> a(2*n);
	for(int i = 0; i < 2*n; i++) {
		cin >> a[i];
		ar.push_back(pii(a[i], i));
	}

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

	for(int i = 0; i < n; i++) {
		b[ar[i].se] = 1;
	}
	string s(2*n, '~');
	stack <int> S;
	for(int i = 0; i < 2*n; i++) {
		if(!S.empty() && b[i] + b[S.top()] == 1) {
			s[i] = ')';
			s[S.top()] = '(';
			//ok
			S.pop();
		}else {
			//not pair with anybody
			S.push(i);
		}
	}
	cout << s << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int O = 2e5 + 1;

int t = 1;

vector <int> c, dp, g[O], Max;

bool how_sort(int x, int y){
    return Max[x] < Max[y];
}

int dfs(int u, int par = 0){
    Max[u] = 0;
    for (int v : g[u]){
        if (v == par) continue;
        dp[v] = dp[u] + 1;
        Max[u] = max(Max[u], dfs(v, u) + 1);
    }
    return Max[u];
}

void dfs1(int u, int par = 0){
    c[u] = t;
    int m = 0;
    for (int v : g[u]){
        if (v == par) continue;
        t += 1;
        dfs1(v, u);
        t += 1;
    }
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    c.resize(n + 1);
    dp.resize(n + 1);
    Max.resize(n + 1);
    for (int i = 1; i < n; ++ i){
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    int compare = 0;
    int root = 1;
    for (int i = 1; i <= n; ++ i){
        if (dp[i] > compare){
            compare = dp[i];
            root = i;
        }
    }
    dfs(root);
    for (int i = 1; i <= n; ++ i){
        sort(g[i].begin(), g[i].end(), how_sort);
    }
    dfs1(root);
    for (int i = 1; i <= n; ++ i) cout << c[i] << " ";
}


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

int main(){
    string s;
    cin >> s;
    vector<int> num(10, 0);
    int size1 = s.size();
    for(int i = 0; i < s.size(); i++){
        num[s[i] - '0']++;
    }

    int hati = 0;
    bool flag;
    while(hati < 1000){
        vector<int> num8(10, 0);
        string moji = to_string(hati);
        for(int i = 0; i < moji.size(); i++){
            num8[moji[i] - '0']++;
        }
        int size2 = moji.size();
        if(size1 > size2) num8[0] += (size1 < 3 ? size1 : 3) - size2;

        flag = true;
        for(int i = 0; i < 10; i++){
            if(num[i] < num8[i]) flag = false;
            //printf("%s : %d < %d\n", moji, num[i], num8[i]);
        }
        if(flag == true) break;

        hati += 8;
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  string s;
  cin >> s;
  vector<ll>v(s.size());
  int n = s.size();
  rep(i,n)v[i] = s[i] - '0';
  vector<ll>ans;
  REP(i,0,999)if((i + 1) % 8 == 0 && ((i + 1) % 10 != 0))ans.push_back(i + 1);
  int sz = ans.size();
  ll cnt = 0;
  ll a,b,c;
  vector<ll>cntt(10);
  cntt[0] = 300000000;
  rep(i,n)cntt[v[i]]++;
  rep(i,sz){
    a = ans[i] % 10;
    ans[i] /= 10;
    b = ans[i] % 10;
    ans[i] /= 10;
    c = ans[i];
    if(c != 0 && b == 0)continue;
    ll check = 0;
    if(a == 0)check++;
    if(b == 0)check++;
    if(c == 0)check++;
    if(check == 1){
      if(n != 2)continue;
    }
    if(check == 2){
      if(n != 1)continue;
    }
    cntt[a]--;
    cntt[b]--;
    cntt[c]--;
    if((cntt[a] >= 0) && (cntt[b] >= 0) && (cntt[c] >= 0)){
      cout << "Yes" << endl;
      return 0;
    }
    cntt[a]++;
    cntt[b]++;
    cntt[c]++;
  }
  cout << "No" << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int const p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int a[55];
int main()
{
    int n,x;long long ans=9e18;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=0;i<(1<<15);i++)
    {
        long long res=1;
        for(int j=0;j<15;j++)
            if(i&(1<<j))res*=p[j];
        int flag=1;
        for(int j=1;j<=n;j++)if(__gcd(res,(long long)a[j])==1){flag=0;break;}
        if(flag)ans=min(ans,res);
    }
    cout<<ans;
    return 0;
}

//code bcuz love,code 4 hate
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<ll,ll>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define MEM(a) memset(a,0,sizeof(a))
#define N 51
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
inline ll lowbit(ll x){return x&(-x);}
ll n,ans=5e18;
ll a[N],p[N],tot,b[N][N];
inline void Solve(ll x,ll v)
{
	ll tmp=v;
	for(re i=2;i*i<=v;i++)
	{
		if(tmp%i==0){b[x][i]=1;while(tmp%i==0)tmp/=i;}
	}
	if(tmp>1){b[x][tmp]=1;}
}
inline ll check(ll x){for(re i=2;i<x;i++)if(x%i==0)return 0;return 1;}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();FOR(i,1,n)a[i]=read(),Solve(i,a[i]);
	FOR(i,2,50)if(check(i))p[++tot]=i;
	FOR(S,0,(1<<tot)-1)
	{
		ll v=1;
		FOR(i,0,tot-1)if((S>>i)&1)v*=p[i+1];
		ll fl=1;
		FOR(i,1,n)
		{
			ll flag=0;
			FOR(j,0,tot-1)if((S>>j)&1)if(b[i][p[j+1]]){flag=1;}
			if(!flag){fl=0;break;}
		}
		if(fl)ans=min(ans,v);
	}
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forl(a,start,end) for(long long a=start;a<end;a++)
#define fi first
#define se second
typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vii;
typedef vector<pll>   vll;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
const double PI = acos(-1);

void solve(){
    /* code */
    string s; cin>>s;
    list<char> l;
    int tm=1;
    fori(i,0,s.size()){
        if(s[i]=='R'){
            tm=1-tm;
        }
        else if(tm){
            if(l.size() && l.back()==s[i]){
                l.pop_back();
            }else{
                l.push_back(s[i]);
            }
        }
        else{
            if(l.size() && l.front()==s[i]){
                l.pop_front();
            }else{
                l.push_front(s[i]);
            }
        }
    }
    if(!tm){
        while(l.size()) {
            cout<<l.back();
            l.pop_back();
        }

    }else{
        for(char c:l) cout<<c;
    }
}

int main()
{
    DONTSYNC;
    // TEST
    solve();
    return 0;
}

#include<ctime>
#include<cstdio>
#include<cctype>
using namespace std;
const int N=2e5+10;
int read() {
	char c;
	int x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
char str[N],stack[N];
int n,f,o,res,top;
int main() {
	#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	res=n;
	scanf("%s",str+1);
	for(int i=1;i<=n;++i){
		switch(str[i]){
			case 'f':
				++top;
				stack[top]='f';
				break;
			case 'o':
				++top;
				stack[top]='o';
				break;
			case 'x':
				if(top&&stack[top]=='o'&&stack[top-1]=='f'){
					stack[top]=0;
					--top;
					stack[top]=0;
					--top;
					res-=3;
				}
				else{
					while(top){
						stack[top]=0;
						--top;
					}
				}
				break;
			default:
				while(top){
					stack[top]=0;
					--top;
				}
				break;
		}
	}
	printf("%d",res);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
using namespace std;

ll cl(ll a, ll b)   {
    if(a%b==0) return a/b;
    else return a/b+1;
}

void solve()    {
    ll n,m;
    cin >> n >> m;
    if(m==0)    {
        cout << "1\n"; return;
    }
    ll a[m];
    for(int i=0; i<m; i++)  cin >> a[i];
    sort(a,a+m);
    ll minpos = 0;
    if(a[0]-1 != 0) minpos = a[0]-1;
    for(int i=1; i<m; i++)  {
        if(minpos == 0) {
            minpos = a[i]-a[i-1]-1;
        }
        if(a[i]-a[i-1]-1 != 0 && a[i]-a[i-1]-1 < minpos)    minpos = a[i]-a[i-1]-1;
    }
    if(minpos == 0) {
        minpos = n-a[m-1];
    }
    if(n-a[m-1] != 0 && n-a[m-1] < minpos)    minpos = n-a[m-1];
    //cout << minpos << endl;
    if(minpos == 0) {
        cout << 0 << endl;
        return;
    }
    ll ans = 0;
    if(a[0]-1 != 0) ans += cl(a[0]-1,minpos);
    for(int i=1; i<m; i++)  {
        if(a[i]-a[i-1]-1 != 0)    ans += cl(a[i]-a[i-1]-1,minpos);
    }
    if(n-a[m-1] != 0) ans += cl(n-a[m-1],minpos);
    cout << ans << endl;
}

int main()  {
    int n=1;
    //cin >> n;
    for(int i=1; i<=n; i++)  {
        solve();
    }
    return 0;
}

#include <algorithm>
#include <bitset>
//#include <cmath>
//#include <complex>
#include <cctype>
#include <cstdio>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int64_t INF = LLONG_MAX;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<int> A(N), B(M);

    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    for(int i = 0; i < M; i++){
        cin >> B.at(i);
    }

    int index = 0;
    set<int> ans;

    for(int tmp : A){
        if(index == M){
            ans.insert(tmp);
            continue;
        }

        bool flag = false;
        for(; index < M; index++){
            if(tmp == B.at(index)){
                flag = true;
                continue;
            }else if(tmp > B.at(index)){
                ans.insert(B.at(index));
            }else{
                break;
            }
        }

        if(flag == false){
            ans.insert(tmp);
        }

    }

    if(index != M){
        for(; index < M; index++){
            ans.insert(B.at(index));
        }
    }

    int count = 0;
    for(int tmp : ans){
        if(count == 0){
            cout << tmp;
        }else{
            cout << " " << tmp;
        }

        count++;
    }
    cout << endl;

    return 0;
}


#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> pi;
typedef tuple<int, int, int> TP;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 201005;
//////////////////////////////

void solve()
{
	Int n, x;
	cin >> n >> x;
	vector<Int> a(n), b(n);
	REP(i, n) cin >> a[i];
	REP(i, n - 1) b[i] = (x%a[i + 1]) / a[i];

	Int dp[51][2] = { 0 };
	dp[0][0] = 1;
	REP(i, n) {
		dp[i + 1][0] += dp[i][0];
		if(b[i] == 0) dp[i + 1][1] += dp[i][1];

		if (b[i]) dp[i + 1][1] += dp[i][1] + dp[i][0];

		if (i == n - 1 || b[i] != a[i + 1] / a[i] - 1) dp[i + 1][0] += dp[i][1];
	}
	cout << dp[n][0] << endl;
}

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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 2*1e5+10;

int a[MAX], b[MAX], p[MAX], q[MAX];
vector<P> ans;
int n;

bool solve() {
    rep(i,n) {
        if (p[i] == i) continue;
        int now = i, start = i, mn = b[p[i]];
        while (q[now] != i) {
            if (chmin(mn, b[p[q[now]]])) start = q[now];
            now = q[now];
        }
        auto f = [&](int now) {
            if (a[now] <= b[p[now]]) return false;
            if (a[q[now]] <= b[p[q[now]]]) return false;
            ans.push_back(P(now + 1, q[now] + 1));
            swap(p[now], p[q[now]]);
            return true;
        };
        while (p[start] != start) {
            if (!f(start)) return false;
            start = q[start];
        }
    }
    return true;
}

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) q[p[i]] = i;
    if (!solve()) cout << -1 << endl;
    else {
        cout << (int)ans.size() << endl;
        rep(i,ans.size()) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

#define int long long int

#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define repd(i, n) for(int i = (int) (n - 1); i >= 0; i--)
#define FOR(i, a, b) for(int i = a; i <= (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

template<typename T>
void load(int n, vector<T> &v) {
  rep(i, n) {
    T a;
    cin >> a;
    v.push_back(a);
  }
}

/// x * y = nとなるような正の整数(x, y)の組
vector<pair<int, int>> pair_of_divisor(int n) {
  vector<pair<int, int>> v;
  for(int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.emplace_back(i, n / i);
    }
  }
  return v;
}

signed main() {
  int s, p;
  cin >> s >> p;

  const auto d = pair_of_divisor(p);
  bool canMake = false;
  for (auto pair : d) {
    if (pair.first + pair.second == s) {
      canMake = true;
    }
  }
  if (canMake) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
#define pq(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<string> s(3);
  rep(i,0,3) cin >> s[i];
  map<char, int> mp;
  rep(i,0,3) {
    for (auto c : s[i]) {
      mp[c] = 1;
    }
  }
  if (len(mp) > 10) {
    cout << "UNSOLVABLE" << endl;
    return 0;
  }
  vector<int> v(10);
  rep(i,0,10) v[i] = i;
  vector<ll> ns(3);
  int idx = 0;
  do {
    ns[0] = ns[1] = ns[2] = 0;
    idx = 0;
    for (auto &p : mp) {
      p.se = v[idx];
      ++idx;
    }
    bool ng = false;
    rep(i,0,3) {
      if (mp[s[i][0]] == 0 && len(s[i]) != 1) {
        ng = true;
        break;
      }
      for (auto c : s[i]) {
        ns[i] *= 10;
        ns[i] += mp[c];
      }
      if (ns[i] == 0) {
		ng = true;
        break;
      }
    }
    if (ng) continue;
    if (ns[0] + ns[1] == ns[2]) {
      printf("%lld\n%lld\n%lld\n", ns[0], ns[1], ns[2]);
      return 0;
    }
  } while(next_permutation(all(v)));
  cout << "UNSOLVABLE" << endl;
  return 0;
}


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

#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x) fixed << setprecision(10) << x
#define mod 1000000007
#define inf 1e18
#define w(tc)  int tc; cin >> tc; for (int i = 1; i <= tc; ++i)
#define PI 3.14159265358979323846264338327950L
#define span(a) begin(a), end(a)
#define ll long long

const int N = 109;
double dp[N][N][N];

double calc(int a, int b, int c) {
	if (a >= 100 or b >= 100 or c >= 100)
		return 0;

	if (dp[a][b][c] >= 0) return dp[a][b][c];

	double tot = a + b + c;
	dp[a][b][c] = 1 + a / tot * calc(a + 1, b, c) + b / tot * calc(a, b + 1, c) + c / tot * calc(a, b, c + 1);

	return dp[a][b][c];
}

inline void solve() {
	memset(dp, -1, sizeof(dp));
	int a, b, c; cin >> a >> b >> c;
	double ans = calc(a, b, c);
	cout << ps(ans);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//w(tc)
	solve();
	return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    cin >> res;
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

double func(){
    int a = in();
    int b = in();
    int c = in();
    method(toint,int,int a,int b,int c){
        return c + 101 * (b + 101 * a);
    };
    vector<double> dp(toint(100,100,100),-1);
    method(func,double,int a,int b,int c){
        if(max({a,b,c})==100){
            return 0;
        }
        double &it = dp[toint(a,b,c)];
        if(it>=0)return it;
        it = 0;
        it += (func(a+1,b,c) + 1) * a / (a + b + c);
        it += (func(a,b+1,c) + 1) * b / (a + b + c);
        it += (func(a,b,c+1) + 1) * c / (a + b + c);
        return it;
    };
    return func(a,b,c);
}

int main(){
    printf("%.20lf\n",func());
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vector<int>>
#define vpii            vector<pair<int,int>>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>
#define sz(s)           (int)s.size()

void KruNULL()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}

int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

void solve()
{
	int n, k;
	cin >> n >> k;
	int sum = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			sum += i * 100 + j;
		}
	}
	cout << sum << endl;
}
int32_t main()
{
	KruNULL();
	// int JUDGE_ONLINE = 1;
	int tc = 1;
	// cin >> tc;
	for (int i = 1; i <= tc; i++)
	{
		// cout << "Case #" << i << ": ";
		solve();
		// if (JUDGE_ONLINE) {
		// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
		// }

	}
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n,m;
    cin >> n >> m;
    ll x=modpow(10,n,m);
    ll y=modpow(10,n,m*m);
    cout << (y-x)/m << endl;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define low(x) ((x)&-(x))
#define ll long long
//#define file
using namespace std;

struct type{
	int s,x;
} A[200001],B[200001];
int n,i,j,k,l;
int a[200001],b[200001];
int tr[200001];
int num[200001];
ll ans;

bool cmp(type a,type b) {return a.s<b.s || a.s==b.s && a.x<b.x;}
void change(int t)
{
	while (t<=n)
	++tr[t],t+=low(t);
}
int find(int t)
{
	int ans=0;
	while (t)
	ans+=tr[t],t-=low(t);
	return ans;
}

int main()
{
	#ifdef file
	freopen("c.in","r",stdin);
	#endif

	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]),a[i]+=i,A[i]=type{a[i],i};
	fo(i,1,n) scanf("%d",&b[i]),b[i]+=i,B[i]=type{b[i],i};
	sort(A+1,A+n+1,cmp);
	sort(B+1,B+n+1,cmp);

	fo(i,1,n)
	{
		if (A[i].s!=B[i].s) {printf("-1\n");return 0;}
		a[A[i].x]=b[B[i].x]=i;
	}

	l=0;
	fo(i,1,n) num[a[i]]=++l;
	fo(i,1,n) a[i]=num[a[i]],b[i]=num[b[i]];
	fo(i,1,n)
	{
		ans+=i-1-find(b[i]);
		change(b[i]);
	}
	printf("%lld\n",ans);

	fclose(stdin);
	fclose(stdout);
	return 0;
}

#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
#define N 2000010
ll lpf[N], mobius[N];

void least_prime_factor()
{
    for (ll i = 2; i < N; i++)

        // If it is a prime number
        if (!lpf[i])

            for (ll j = i; j < N; j += i)

                // For all multiples which are not
                // visited yet.
                if (!lpf[j])
                    lpf[j] = i;
}
void Mobius()
{
    for (ll i = 1; i < N; i++) {

        // If number is one
        if (i == 1)
            mobius[i] = 1;
        else {

            // If number has a squared prime factor
            if (lpf[i / lpf[i]] == lpf[i])
                mobius[i] = 0;

            // Multiply -1 with the previous number
            else
                mobius[i] = -1 * mobius[i / lpf[i]];
        }
    }
}
ll gcd_pairs(ll a[],ll n)
{
    // To store maximum number
    ll maxi = 0;

    // To store frequency of each number
    ll fre[N] = { 0 };

    // Find frequency and maximum number
    for (ll i = 0; i < n; i++) {
        fre[a[i]]++;
        maxi = max(a[i], maxi);
    }

    least_prime_factor();
    Mobius();

    // To store number of pairs with gcd equals to 1
    ll ans = 0;

    // Traverse through the all possible elements
    for (ll i = 1; i <= maxi; i++) {
        if (!mobius[i])
            continue;

        ll temp = 0;
        for (ll j = i; j <= maxi; j += i)
            temp += fre[j];

        ans += temp * (temp - 1) / 2 * mobius[i];
    }

    // Return the number of pairs
    return ans;
}
int main()
{
    IO
    ll l,r;
    cin>>l>>r;
    ll n=r-l+1;
    ll final=(n*(n-1))/2;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
    	a[i]=l+i;
    }
    for(ll i=l;i<=r;i++)
    {
    	final-=((r/i)-1);
    }
    if(l==1)
    {
        final+=n-1;
    }
    final-=gcd_pairs(a,n);
    cout<<final*2<<lc;
    return 0;
}
/*
	Well, why don't you just concentrate
	on being the best you, you can be.
*/


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

const ll N = 100000000;

string S[3];
string T;
ll mp[N];

ll g(string S){
	ll ret = 0;
	for(int i = 0; i<S.size(); i++){
		ret*=10;
		ret+=mp[S[i]];
	}
	return ret;
}

bool f(vector<int>  v){
	for(int i = 0; i<T.size(); i++){
		mp[T[i]] = v[i];
	}
	for(int i = 0; i<3; i++){
		if(mp[S[i][0]]==0) return false;
	}
	if(g(S[0])+g(S[1])==g(S[2])){
		cout<<g(S[0])<<'\n'<<g(S[1])<<'\n'<<g(S[2])<<'\n'; return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i<3; i++){
		cin>>S[i];
		T+=S[i];
	}
	sort(T.begin(), T.end());
	T.erase(unique(T.begin(), T.end()), T.end());
	if(T.size()>10){
		cout<<"UNSOLVABLE\n";
		return 0;
	}
	vector<int> v;
	for(int i = 0; i<10; i++) v.push_back(i);
	do{
		if(f(v)) return 0;
	} while(next_permutation(v.begin(), v.end()));
	cout<<"UNSOLVABLE\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define MOD 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t;cin>>t;
    //while(t--)
    int a,b,c;cin>>a>>b>>c;
    char ans;
    if(c%2 == 1)
    {
        if(a>b)
        ans = '>';
        else if(a<b)
        ans = '<';
        else
        ans = '=';
    }
    else
    {
        if(abs(a) > abs(b))
        {
            ans = '>';
        }
        else if(abs(a) < abs(b))
        {
            ans = '<';
        }
        else
        {
            ans = '=';
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long>
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
char c[20];
int n, m;
ll cnt[20];
bool jdg[20];
vector<char> to[20];
vector<vector<char>> v;

void dfs1(char x) {
    if (jdg[x]) return;
    jdg[x] = true;
    v.back().epb(x);
    for (auto &i: to[x]) dfs1(i);
    return;
}

void dfs2(char x, char y) {
    if (c[v[x][y]] >= 0) return;
    rep(i, 3) {
        bool con = false;
        for (auto &j: to[v[x][y]]) {
            if (i == c[j]) {
                con = true;
                break;
            }
        }
        if (con) continue;
        c[v[x][y]] = i;
        if (y + 1 < v[x].size()) dfs2(x, y + 1);
        else cnt[x]++;
    }
    c[v[x][y]] = -1;
    return;
}

int main() {
    ci2(n, m);
    rep(i, m) {
        int a, b;
        ci2(a, b);
        to[a - 1].epb(b - 1);
        to[b - 1].epb(a - 1);
    }
    rep(i, n) {
        if (jdg[i]) continue;
        v.epb(vector<char>(0));
        dfs1(i);
    }
    fill(c, c + n, -1);
    rep(i, v.size()) dfs2(i, 0);
    ll ans = 1;
    rep(i, v.size()) ans *= cnt[i];
    co(ans);
    return 0;
}

//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
template<typename T>void rearrange(vector<ll>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<ll>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  struct edge{
    ll to,id,rev;
  };
  vector<vector<edge>>g(n);
  rep(i,0,m){
    ll u,v;cin>>u>>v;u--;v--;
    g[u].PB({v,i,0});
    g[v].PB({u,i,1});
  }
  vector<ll>c(n);
  rep(i,0,n)cin>>c[i];
  vector<ll>ord(n);
  iota(ALL(ord),0);
  sort(ALL(ord),[&](ll i,ll j)
    {
      return c[i]<c[j];
    }
  );
  vector<bool>used(n);
  vector<ll>ed(m,-1);
  for(auto i:ord){
    if(used[i])continue;
    auto dfs=[&](auto &&f,ll k)->void{
      used[k]=true;
      for(auto e:g[k]){
        if(ed[e.id]!=-1)continue;
        if(c[e.to]>c[i])continue;
        ed[e.id]=e.rev;
        if(used[e.to])continue;
        f(f,e.to);
      }
    };
    dfs(dfs,i);
  }
  //debug(ed,m);
  rep(i,0,m){
    ans(!ed[i],"->","<-");
  }
  return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int n = input();

  vector< i64 > as(n), ts(n);
  range(i, 0, n) cin >> as[i] >> ts[i];

  auto fr = [&](i64 x) {
    range(i, 0, n) {
      if (ts[i] == 1) x += as[i];
      if (ts[i] == 2) x = max(x, as[i]);
      if (ts[i] == 3) x = min(x, as[i]);
    }
    return x;
  };

  i64 tp = fr(infll);
  i64 bm = fr(-infll);

  i64 l, h;
  { // l
    i64 ok = -infll;
    i64 ng = inf;
    while (abs(ok - ng) > 1) {
      i64 mid = (ok + ng) / 2;
      if (fr(mid) == bm) ok = mid;
      else ng = mid;
    }
    l = ok;
  }
  { // h
    i64 ok = infll;
    i64 ng = -infll;
    while (abs(ok - ng) > 1) {
      i64 mid = (ok + ng) / 2;
      if (fr(mid) == tp) ok = mid;
      else ng = mid;
    }
    h = ok;
  }

  auto f = [&](i64 x) {
    if (x <= l) return bm;
    if (x >= h) return tp;
    return bm + x - l;
  };

  int q = input();
  range(i, 0, q) {
    i64 x = input();
    cout << f(x) << endl;
  }
}

signed main() {
  solve();
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll INF = 10000000000;

typedef ll num_t;

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	set<int> stops;
	for (int i = 0; i < K; ++i) {
		int tmp; cin >> tmp; stops.insert(tmp);
	}

	int cnt = 0;
	for (int i = 0; i <= N; ++i) {
		if (stops.find(i) != stops.end()) {
			++cnt;
			if (cnt == M) {
				cout << -1 << endl;
				return 0;
			}
		}
		else cnt = 0;
	}

	vector<double> a(N + M), b(N + M);
	for (int i = N; i < N + M; ++i)
		a[i] = b[i] = 0;

	double a_sum = 0, b_sum = 0;
	for (int i = N - 1; i >= 0; --i) {
		if (stops.find(i) != stops.end()) {
			a[i] = 1; b[i] = 0;
		}
		else {
			a[i] = a_sum / M;
			b[i] = b_sum / M + 1;
		}

		a_sum += a[i]; b_sum += b[i];
		a_sum -= a[i + M]; b_sum -= b[i + M];
	}

	cout.precision(10);
	cout << (b[0] / (1 - a[0])) << endl;

	return 0;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n), wb(n, 0);
  REP(i, n) cin >> a[i], --a[i];
  REP(i, n) cin >> b[i], --b[i];
  REP(i, n) {
    int c; cin >> c; --c;
    ++wb[c];
  }
  vector<int> cnt(n, 0);
  REP(i, n) cnt[b[i]] += wb[i];
  ll ans = 0;
  REP(i, n) ans += cnt[a[i]];
  cout << ans << '\n';
  return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+5;
int n,shu1[maxn],shu2[maxn],shu3[maxn];
int ans,num1[maxn],num2[maxn],num3[maxn],num[maxn];
signed main()
{
	#ifndef LZVTJL
	ios::sync_with_stdio(false);
	#endif
	cin>>n;
	for(int i=1;i<=n;++i)cin>>shu1[i];
	for(int i=1;i<=n;++i)cin>>shu2[i];
	for(int i=1;i<=n;++i)cin>>shu3[i];
	for(int i=1;i<=n;++i)++num3[shu3[i]];
	for(int i=1;i<=n;++i)num2[shu2[i]]+=num3[i];
	for(int i=1;i<=n;++i)++num1[shu1[i]];
	for(int i=1;i<=n;++i)ans+=num1[i]*num2[i];
	cout<<ans;
}


#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstring = vector<string>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) { return o << "{" << p.first << "," << p.second << "}"; }
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) { for(auto &v : vec) { is >> v; } return is; }
template<typename T> inline ostream& operator<<(ostream &os, vector<T> &vec) {
    //for(auto &v : vec) { os << v << ",";}
    for(auto &v : vec) { os << v << endl;}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline void chmax(T &a, T b) { a = max(a, b); }

ll x,y,a,b;

bool ok(ll n)
{
    ll d = y-x-1;
    if(d/n >= b) {
        return true;
    }
    if(x >= b) {
        return false;
    } else {
        ll x1 = x;
        while(n) {
            if(x1 * a> x+b) { break; }
            x1 *= a;
            n--;
        }
        if(n==0) { return false; }
        ll d1 = y-x1-1;
        if(d1/n >= b) {
            return true;
        } else {
            return false;
        }
    }
}

int main(void)
{
    cin >> x >> y >> a >> b;

    ll l = 0, r = LINF;

    while(r-l>1) {
        ll m = (r+l)/2;
        if(ok(m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;
    return 0;
} /*atcoder*/

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll x, y, a, b;
	cin >> x >> y >> a >> b;

	ll ans = 0;
	while((double) a * x < 2e18 && a * x < y && a * x <= x + b){
		x *= a;
		ans++;
	}

	ans += (y - 1 - x) / b;
	cout << ans << endl;
}


#include<bits/stdc++.h>
#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)
#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)
#define ll long long
#define ull unsigned long long
#define db long double
#define pii pair<int, int>
#define mkp make_pair
using namespace std;
const int N = 1e6 + 7;
int n;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	cout << 100 - n % 100 << "\n";
    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long long ll;
#define G getchar()
ll read()
{
	ll x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second
/*
const int mod=;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,const int &y){x=upd(x+y-mod);}
inline void iadd(int &x,const int &y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}
*/
//typedef pair<int,int> P;
#define rep(i,l,r) for (int i(l),_##i(r);i<=_##i;i++)
#define per(i,l,r) for (int i(r),_##i(l);i>=_##i;i--)
#define all(x) (x).begin(),(x).end()
#define forall(x,y) for (const int &y: e[x])

int n;
int getid(){
	char s[2];
	scanf("%s",s);
	if (s[0]=='R') return 0;
	if (s[0]=='G') return 1;
	return 2;
}

vector<ll> S[3];

void solve(){
	n=read()<<1;
	rep(i,1,n){
		ll x=read();
		S[getid()].pb(x);
	}
	rep(i,0,2) sort(all(S[i]));
	if (S[0].size()&1^1&&S[1].size()&1^1) return puts("0"),void();
	if (S[0].size()&1^1) swap(S[0],S[2]);
	if (S[1].size()&1^1) swap(S[1],S[2]);
	auto A=S[0],B=S[1];
	ll z=1e18; int p=0;
	for (ll x: A){
		while (p<B.size()&&B[p]<=x) ++p;
		if (p<B.size()) z=min(z,abs(B[p]-x));
		if (p) z=min(z,abs(B[p-1]-x));
	}
	ll a=1e18,b=1e18;
	A=S[0],B=S[2]; p=0;
	for (ll x: A){
		while (p<B.size()&&B[p]<=x) ++p;
		if (p<B.size()) a=min(a,abs(B[p]-x));
		if (p) a=min(a,abs(B[p-1]-x));
	}
	A=S[1],B=S[2]; p=0;
	for (ll x: A){
		while (p<B.size()&&B[p]<=x) ++p;
		if (p<B.size()) b=min(b,abs(B[p]-x));
		if (p) b=min(b,abs(B[p-1]-x));
	}
	z=min(z,a+b);
	printf("%lld\n",z);
}

int main()
{
	for (int T=1;T--;) solve();
	return 0;
}


#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
// #define M_PI 3.14159265358979323846 // CF
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // print Decimal number 10 Rank
#define endl "\n"
#define Case(x) printf("Case #%d: ", x); // gcj

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<char> vch;
typedef vector<vector<char>> vvch;

constexpr ll LINF = 1001002003004005006ll;
constexpr int INF = 1002003004;
constexpr int n_max = 2e5+10;

template<class T>
inline bool chmax(T &a, T b) { if(a<b) { a=b; return true; } return false; };
template<class T>
inline bool chmin(T &a, T b) { if(a>b) { a=b; return true; } return false; };

template<class T, class U>
T POW(T x, U n) {T ret=1; while (n>0) {if (n&1) {ret*=x;} x*=x; n>>=1;} return ret;};

// debug
template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';};
string to_string(const char c) {return to_string((string) &c);};
string to_string(bool b) {return (b ? "true" : "false");};
template <size_t N>
string to_string(bitset<N> v){
  string res = "";
  for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
};
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for(const auto &x : v) {
    if(!first) res += ", ";
    first = false; res += to_string(x);
  }
  res += "}";
  return res;
};
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;};
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); };

void LINE_OUT() {
  cout << "--------------" << endl;
};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define LINE LINE_OUT();
#else
#define debug(...) 71
#define LINE 71;
#endif

void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ld sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
  gy = -gy;

  ld ans = -sy*(gx-sx)/(gy-sy) + sx;
  Decimal(ans);

  return 0;
};

#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    double sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    double diff = abs(sx - gx);

    double len = diff / (sy + gy) * sy;
    double ans = sx;
    if (sx < gx) ans += len;
    else ans -= len;
    cout << fixed << setprecision(7);
    cout << ans << '\n';
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll mod = 1e9 + 7;

int main() {
	int t;
	cin >> t;
	rep(i, t) {
		ll n, a, b;
		cin >> n >> a >> b;
		ll c = (n - a + 1) * (n - b + 1) % mod;
		ll r = max(0LL, n - a - b + 1);
		ll t = (r * (r + 1) / 2) % mod;
		ll x = c * t % mod;
		ll y = t * t % mod;
		ll ans = 4 * (x - y) % mod;
		cout << (ans + mod) % mod  << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define Rep(i,j,n) for (ll i=(ll)(j);i<=(ll)(n);++i)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int mod = 998244353;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

/*
ll ti=clock();
cout<<("Execution Time: %.4lf sec", 1.0 * (clock() - ti) / CLOCKS_PER_SEC)<<endl;
*/

int main(){
  ll n;
  cin>>n;
  vl a(n),x(n);
  vector<Pll> p;
  rep(i,n){
    ll P;
    cin>>a[i]>>P>>x[i];
    p.pb(mp(P,i));
  }
  sort(all(p));
  rep(i,n){
    ll shop=p[i].S;
    if(x[shop]>a[shop]){
      print(p[i].F);
      return 0;
    }
  }
  print(-1);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 61;
const ll mod =998244353;

int main() {
	int n, m;
	cin >> n >> m;
	VLL a(2);
	REP(i, n) {
		string s;
		cin >> s;
		int cnt = 0;
		REP(j, m) {
			if (s[j] == '1')cnt++;
		}
		a[cnt % 2]++;
	}
	cout << a[0] * a[1] << endl;

}

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+2;
int n,m,cn[2];
long long ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int x;n;--n)
	{
		int val=0;
		for(int j=m-1;~j;--j)
		{
			scanf("%1d",&x);
			val^=x;
		}
		ans+=cn[!val];
		++cn[val];
	}
	printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  if (s[0] == 'Y') {
    if (t[0] >= 'A' && t[0] <= 'Z')
      cout << char(t[0]);
    else
      cout << char(t[0] - 'a' + 'A');
  } else {
    cout <<char( t[0]) << "\n";
  }

  return 0;
}
//10.10.2020 20:00:47 CST

#include<bits/stdc++.h>
using namespace std;
int main()
{
  char S,T;
  cin >> S >> T;
  if(S=='Y')
  {
    if(T=='a')
    {
      cout<<'A'<<endl;
      return 0;
    }
    if(T=='b')
    {
      cout<<'B'<<endl;
      return 0;
    }
    if(T=='c')
    {
      cout<<'C'<<endl;
      return 0;
    }
  }
    else
    {
      cout<<T<< endl;
    }
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

vector<string> f(int n){
    if(n == 1)  return vector<string>{"AB"};
    vector<string> ans = f(n - 1);
    int sz = ans.size();
	for(int t = 0; t < sz; ++t){
        ans[t] = ans[t] + ans[t];
        string s = ans[t];
        int siz = s.size();
        for(int i = siz / 2; i < siz; ++i)  s[i] = "AB"[s[i] == 'A'];
        ans.emplace_back(s);
    }
    string s(1 << (n - 1), 'A'),  ss(1 << (n - 1), 'B');
    ans.emplace_back(s + ss);
    return ans;
}

int n;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    cin >> n;
    vector<string> s = f(n);
    cout << s.size() << "\n";
    for(auto &v : s)  cout << v << "\n";
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){
        cout << i - 1 << endl;
        return 0;
    }
}


#include<iostream>
#include<cstdio>

using namespace std;

#define M 100009
#define endl "\n"
#define pb push_back
#define ll long long int
#define mod7 1000000009

int main()
{
  /*
#ifndef inout
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/

	int n;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << "White" << endl;
	}
	else cout << "Black" << endl;

	return 0;
}

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

long long solve(long long N){
	vector<int>A;
	while(N){
		A.push_back(N%10);
		N/=10;
	}
	const int INF=1<<29;
	int res=INF;
	for(int bit=0;bit<(1<<A.size())-1;bit++){
		int sum=0,con=0;
		for(int i=0;i<A.size();i++){
			if(bit&(1<<i)){
				con++;
			}
			else sum += A[i];
		}
		if(sum%3==0){
			res=min(res,con);
		}
	}
	return(res<INF?res:-1);
}

int main() {
	long long N;
	cin >> N;
	cout << solve(N) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define REP(i,x,n) for(ll i = (x); i < (n); ++i)
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

template<class T> inline bool chmin(T& a, T b){ if(a > b) { a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a = b; return true;} return false; }
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }

vector<ll> fa;
ll find(ll x){
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main(void)
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    fa = vector<ll>(n);
    rep(i,n) fa[i] = i;
    rep(i,m){
        ll c, d;
        cin >> c >> d;
        c--; d--;
        c = find(c);
        d = find(d);
        if(c != d) fa[c] = d;
    }
    vector<ll> l(n), r(n);
    rep(i,n){
        l[find(i)] += a[i];
        r[find(i)] += b[i];
    }
    rep(i,n){
        if(l[i] != r[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

#include <iostream>
#include <string>
#include <map>
#include<vector>
#include <cmath>
using namespace std;
#define ll long long
vector<int> in;
vector<int> adj[200001];
bool visited[200001];
void dfs(int x) {
    visited[x] = true;
    in.push_back(x);
    for(int next : adj[x]) {
        if(!visited[next]) dfs(next);
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    int v[n], a[n], b[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) v[i] = a[i]-b[i];
    for(int i=0;i<m;i++) {
        int c,d;
        cin >> c >> d;
        --c, --d;
        adj[c].push_back(d), adj[d].push_back(c);
    }
    bool work = true;
    for(int i=0;i<n && work;i++) {
        if(!visited[i]) {
            in.clear();
            dfs(i);
            ll sum = 0;
            for(auto &it : in) sum+=v[it];
            if(sum!=0) work = false;
        }
    }
    if(!work) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int n, m;
int f[105][105], pw[105];
char s[105];

inline int get(char ch)
{
	if(ch == 'P') return 0;
	if(ch == 'R') return 1;
	return 2;
}

inline int check(int a, int b)
{
	if(a == 0) return b == 2 ? 2 : 0;
	if(a == 1) return b == 0 ? 0 : 1;
	return b == 1 ? 1 : 2;
}

int main()
{
	scanf("%d %d", &n, &m);
	scanf("%s", s + 1);

	pw[0] = 1;
	for(int i = 1; i <= m; i++) pw[i] = 2ll * pw[i - 1] % n;

	for(int i = 1; i <= n; i++) f[i][0] = get(s[i]);
	for(int j = 1; j <= m; j++)
		for(int i = 1; i <= n; i++)
			f[i][j] = check(f[i][j - 1], f[ (i - 1 + pw[j - 1]) % n + 1 ][j - 1]);

	if(f[1][m] == 0) puts("P");
	if(f[1][m] == 1) puts("R");
	if(f[1][m] == 2) puts("S");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
char str[205],tmp[205];
char F(char x,char y){
	if(x==y)return x;
	if(x=='S'&&y=='P')return x;
	if(x=='P'&&y=='R')return x;
	if(x=='R'&&y=='S')return x;
	return y;
}
int main(){
	cin>>n>>k>>str+1;
	for(int j=1;j<=n;j++)str[j+n]=str[j];
	for(int i=1;i<=k;i++){
		for(int j=1;j<=n;j++)tmp[j]=F(str[2*j-1],str[2*j]);
		for(int j=1;j<=n;j++)str[j]=str[j+n]=tmp[j];
		//for(int j=1;j<=n;j++)cout<<str[j];cout<<endl;
	}
	cout<<str[1];
    return 0;
}
/**/


#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
int s,k,a[805][805],b[805][805];
vector<int>ve;
bool judge(int x){
	for(int i=1;i<=s;++i)
		for(int j=1;j<=s;++j)
			b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(a[i][j]>x);
	for(int i=k;i<=s;++i)
		for(int j=k;j<=s;++j)
			if(b[i][j]-b[i-k][j]-b[i][j-k]+b[i-k][j-k]<=(k*k>>1))
				return 1;
	return 0;
}
int main(){
	s=read,k=read;
	for(int i=1;i<=s;++i)
		for(int j=1;j<=s;++j)
			a[i][j]=read,ve.push_back(a[i][j]);
	sort(ve.begin(),ve.end());
	int l=0,r=ve.size()-1,mid,ans=0;
	while(l<=r)judge(ve[mid=l+r>>1])?r=(ans=mid)-1:l=mid+1;
	cout<<ve[ans];
	return 0;
}

#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vv<int> A = vvec(N, N, 0);
    rep(i, N) rep(j, N) cin >> A[i][j];

    int low = -1, high = 1e9;
    vv<int> B = vvec(N + 1, N + 1, 0);
    while (high - low > 1) {
        int mid = (low + high) / 2;
        rep(i, N) rep(j, N) {
            B[i + 1][j + 1] = B[i + 1][j] + B[i][j + 1] - B[i][j] + (A[i][j] > mid);
        }
        bool ok = false;
        int border = K * K / 2 + 1;
        rep(i, 0, N - K + 1) rep(j, 0, N - K + 1) {
            int c = B[i + K][j + K] - B[i + K][j] - B[i][j + K] + B[i][j];
            if (c < border) ok = true;
        }
        if (ok) high = mid;
        else low = mid;
    }
    write(high);
}


//红太阳zhouakngyang txdy!
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#define Macesuted cout<<"kawaii"<<endl
#define MatrixCascade cout<<"npsl"<<endl
#define Karry5307 cout<<"nmsl"<<endl
using namespace std;
#define int long long
inline int read()
{
	int sum=0,nega=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')nega=-1;ch=getchar();}
	while(ch<='9'&&ch>='0')sum=sum*10+ch-'0',ch=getchar();
	return sum*nega;
}
const int N=2e5+9,mod=998244353,M=4e5+9;
int n,a[N],b[N],ans,c[M];
struct point
{
	int x,pos;
}ax[N],bx[N];
map <int,int> mp;
int tim;
vector<int> pa[N],pb[N];
inline int lowbit(int x)
{
	return x&(-x);
}
inline void add(int x,int k)
{
	while(x<=M)
	{
		c[x]+=k;x+=lowbit(x);
	}
}
inline int query(int x)
{
	int res=0;
	while(x!=0)
	{
		res+=c[x];x-=lowbit(x);
	}
	return res;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),ax[i].x=a[i]+i-1,ax[i].pos=i;
	for(int i=1;i<=n;i++)b[i]=read(),bx[i].x=b[i]+i-1,bx[i].pos=i;
	for(int i=1;i<=n;i++)
		if(!mp[ax[i].x])mp[ax[i].x]=++tim;
	for(int i=1;i<=n;i++)pa[mp[ax[i].x]].push_back(i);
	for(int i=1;i<=n;i++)
	{
		if(!mp[bx[i].x])
		{
			puts("-1");return 0;
		}
		pb[mp[bx[i].x]].push_back(i);
	}
	for(int i=1;i<=tim;i++)
	{
		if(pa[i].size()!=pb[i].size())
		{
			puts("-1");return 0;
		}
		for(int j=0;j<pa[i].size();j++)
		{
			a[pa[i][j]]=pb[i][j];
		}
	}
//	for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
	for(int i=1;i<=n;i++)
	{
		ans+=(i-1-query(a[i]));
		add(a[i],1);
	//	cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return MAXL;if(a<=l&&r<=b)return Mi[k]+A[k];
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
};

StarrySkyTree t;

void Main() {
  ll n;
  R n;
  ll a[n],b[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  ll s1=0,s2=0;
  rep(i,n) {
    s1+=a[i];
    s2+=b[i];
  }
  if(s1!=s2) {
    pr(-1);
    return;
  }
  rep(i,n) {
    a[i]+=i;
    b[i]+=i;
  }
  t.init();
  map<ll,queue<ll> > m;
  rep(i,n) m[a[i]].push(i);
  ll ans=0;
  rep(i,n) {
    if(m[b[i]].empty()) {
      pr(-1);
      return;
    }
    ll k=m[b[i]].front();m[b[i]].pop();
    ll x=k+t.getMin(k,k+1);
    ans+=x-i;
    t.add(0,k,1);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){
    return v2<T>(r, vector<T>(c, t));
}
#define F first
#define S second

void solve(){
    ll n;
    cin >> n;

    ll lo = 0;
    ll hi = 2e9;
    ll highest = -1;
    while(lo <= hi){
        ll mid = (lo+hi)/2;
        ll sum = (mid*(mid+1))/2;
        if(sum <= n+1){
            highest = mid;
            lo = mid+1;
        }
        else{
            hi = mid-1;
        }
    }
    assert(highest != -1);

    ll ans = n - highest + 1;
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

// Author: rifatrraazz
// Time: 2021-05-10 10:25:19
// Problem: A - Century
// TL: 2000ms 		ML: 1024MB
// URL: https://atcoder.jp/contests/abc200/tasks/abc200_a

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define ff first
#define ss second

#define yes cout << "Yes\n"
#define no cout << "No\n"
#define Case(i) cout << "Case " << int(i) << ": "
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x, y) cout << #x << " = " << x << "\t" << #y << " = " << y << endl

#define lop(n) for (int i = 0; i < n; i++)
#define lopj(n) for (int j = 0; j < n; j++)
#define mem0(a) memset(a, 0, sizeof a)
#define mem1(a) memset(a, -1, sizeof a)

#define all(x) x.begin(), x.end()
#define sorta(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.rbegin(), x.rend())
#define bitcount(x) __builtin_popcount(x)

#define vin vector<int>
#define vll vector<ll>
#define vst vector<string>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define vpll vector<pll>
#define vpii vector<pii>

#define fread freopen("input.txt", "r", stdin)
#define fwrite freopen("output.txt", "w", stdout)
#define fastio  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PI acos(-1.0)

using namespace std;

int main()
{
  fastio;

  int n; cin >> n;
  cout << (n + 99) / 100;

  return 0;
}

/* int dr[] = {1,-1,0,0}
   int dc[] = {0,0,1,-1}; */
// 4 Direction
/* int dr[] = {1,-1,0,0,1,1,-1,-1}
   int dc[] = {0,0,1,-1,1,-1,1,-1}; */
// 8 Direction
/* int dr[] = {1,-1,1,-1,2,2,-2,-2}
   int dc[] = {2,2,-2,-2,1,-1,1,-1}; */
// Knight Direction
/* int dr[] = {2,-2,1,1,-1,-1}
   int dc[] = {0,0,1,-1,1,-1}; */
// Hexagonal Direction

// bitmask operations
/*
int Set(int n, int pos) { return n = n | (1 << pos); }
int reset(int n, int pos) { return n = n & ~(1 << pos); }
bool check(int n, int pos) { return (bool)(n & (1 << pos)); }
*/


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

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>ans(n+1);
  for(int i=1;i<=n;i++){
    ans[i].first=i*2%n;
    ans[i].second=(i*2+1)%n;
  }
  for(int i=1;i<=n;i++)cout<<ans[i].first+1<<' '<<ans[i].second+1<<'\n';
}

#include<iostream>
using namespace std;
int n,i;
int main(){
	cin>>n;
	for(i=1;i<=n;++i){
		cout<<((i+1)>>1)<<" "<<((i+n+1)>>1)<<endl;
	}
}


/*input
12
5 2
5 6
1 2
9 7
2 7
5 5
4 2
6 7
2 2
7 8
9 7
1 8

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=4e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    a%=MOD;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
bool vis[maxn];
int cnt=0;
int num=0;
void dfs(int u){
    vis[u]=1;
    num++;
    for(int x:v[u]){
        if(!vis[x]){
            ++cnt;
            dfs(x);
        }
        else ++cnt;
    }
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    set<int> s;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        s.insert(a),s.insert(b);
        v[a].pb(b);
        v[b].pb(a);
    }
    int ans=sz(s);
    for(auto x:s){
        if(!vis[x]){
            cnt=num=0;
            dfs(x);
            if(cnt==2*(num-1)) --ans;
        }
    }
    cout<<ans;
}