#include <bits/stdc++.h>

#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef ld typ;
typedef string str;

struct point
{
    ld x, y;
};

struct vec
{
    ld a, b;
};

struct line
{
    ld a, b, c;
};

const ll MaxN = 1e6;
const ld eps = 1e-8;
const ll MaxNN = 1e3;

void build(ll, ll, ll);
ll _max(ll, ll, ll, ll, ll);
void update(ll, ll, ll, ll, ll, ll);
typ sqr(typ);
void start();
void extended(int);
point cin_point();
void cout_point(point);
point n_point(point, point);
vec mv(point, point);
line ml(point, point);
typ croos(vec, vec);
typ skalar(vec, vec);

int a[100000], d[400000], updateb[400000];

int main()
{
    start();

    ll a[110];
    ll n, m, f, k;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> k >> f;
        if (k == n)
        {
            cout << f;
            return 0;
        }
        else
            a[k] = f;
    }
    for (int i = 1; i < n; i++)
        if (a[i] - a[i - 1] == 1)
        {
            //i - 1 - ��������� �������� �� a[i - 1] �����
            if ((i - 1) % a[i - 1])
                return cout << -1 << endl, 0;
            ll b = (i - 1) / a[i - 1];
            cout << (n - 1) / b + 1 << endl;
            return 0;
        }
    cout << -1 << endl;
    return 0;
}

void build(ll v, ll tl, ll tr)
{
    if (tl == tr)
        d[v] = a[tl];
    else
    {
        ll tm = (tl + tr) / 2;
        build(v * 2, tl, tm);
        build(v * 2 + 1, tm + 1, tr);
        d[v] = max(d[v * 2], d[v * 2 + 1]);
    }
}

ll _max(ll v, ll tl, ll tr, ll l, ll r)
{
    if (l > r)
        return 0;
    if (tl == l && tr == r)
        return d[v] + updateb[v];
    ll tm = (tl + tr) / 2;
    return max(_max(v * 2, tl, tm, l, min(r, tm)), _max(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)) + updateb[v];
}

void update(ll v, ll tl, ll tr, ll l, ll r, ll s)
{
    if (l > r)
        return;
    if (tl == l && tr == r)
    {
        updateb[v] += s;
        return;
    }
    ll tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(r, tm), s);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, s);
}

ld sqr(ld a)
{
    return a * a;
}

void start()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void extended(int n)
{
    cout << setprecision(n) << fixed;
}

point cin_point()
{
    point a;
    cin >> a.x >> a.y;
    return a;
}

void cout_point(point a)
{
    cout << a.x << ' ' << a.y << endl;
}

point n_point(point a, point b)
{
    point n;
    n.x = a.x;
    n.y = b.y;
    return n;
}

vec mv(point st, point fn)
{
    vec v;
    v.a = fn.x - st.x;
    v.b = fn.y - st.y;
    return v;
}

line ml(point a, point b)
{
    line l;
    l.a = b.y - a.y;
    l.b = a.x - b.x;
    l.c = -l.a * a.x - l.b * a.y;
    return l;
}

typ skalar(vec a, vec b)
{
    return a.a * b.a + a.b * b.b;
}

typ cross(vec a, vec b)
{
    return a.a * b.b - a.b * b.a;
}


// ConsoleApplication1.cpp: определяет точку входа для консольного приложения.
//

//#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

pair<ll, ll> a[111];
ll n, m;

bool check(ll mm)
{
	for (int i = 0; i < m; i++)
		if (a[i].x / mm <= a[i].y - 1)
			return 0;
	return 1;
}

bool check1(ll mm)
{
	for (int i = 0; i < m; i++)
		if (a[i].x / mm < a[i].y - 1)
			return 0;
	return 1;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> a[i].x >> a[i].y;
	ll l = 0, r = 1e15;
	while (r - l > 1)
	{
		ll mm = (l + r) / 2;
		if (check(mm))
			l = mm;
		else
			r = mm;
	}
	ll right = r;
	l = 0, r = 1e15;
	while (r - l > 1)
	{
		ll mm = (l + r) / 2;
		if (check1(mm))
			l = mm;
		else
			r = mm;
	}
	ll left = l;
	if (n / left != n / right)
		cout << -1;
	else
		cout << n / left + 1;
	cout << endl;
	//system("pause");
    return 0;
}


// ConsoleApplication1.cpp: определяет точку входа для консольного приложения.
//

//#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

pair<ll, ll> a[111];
ll n, m;

bool check(ll mm)
{
	for (int i = 0; i < m; i++)
		if ((a[i].x - 1) / mm < a[i].y - 1)
			return 0;
	return 1;
}

bool check1(ll mm)
{
	for (int i = 0; i < m; i++)
		if ((a[i].x - 1) / mm > a[i].y - 1)
			return 0;
	return 1;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> a[i].x >> a[i].y;
	ll l = 0, r = 1e15;
	while (r - l > 1)
	{
		ll mm = (l + r) / 2;
		if (check(mm))
			l = mm;
		else
			r = mm;
	}
	//cout << "     " << l << ' ' << r << endl;
	ll right = l;
	l = 0, r = 1e15;
	while (r - l > 1)
	{
		ll mm = (l + r) / 2;
		if (check1(mm))
			r = mm;
		else
			l = mm;
	}
	//cout << "     " << l << ' ' << r << endl;
	ll left = r;
	//cout << n / left << ' ' << n / right << endl;
	if ((n - 1) / left != (n - 1) / right)
		cout << -1;
	else
		cout << (n - 1) / left + 1;
	cout << endl;
	//system("pause");
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        for (int i = 1; i < x / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i < n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        for (int i = 1; i < (x + k - 1) / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i <= n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    if (answer == -1){
        cout << answer << endl;
        return 0;
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        if (x == n){
            cout << k << endl;
            return 0;
        }
        for (int i = 1; i < (x + k - 1) / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i <= n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    if (answer == -1){
        cout << answer << endl;
        return 0;
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

bool check(char c){
    return c != 'a' || c != 'u' || c != 'e' || c != 'i' || c != '0';
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        for (int i = 1; i < x / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i <= n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    if (answer == -1){
        cout << answer << endl;
        return 0;
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > s(m);
    for (int i = 0; i < m; i++)
        cin >> s[i].first >> s[i].second;
    vector<int> answer;
    for (int l = 1; l <= 1000; l++){
        bool flag = true;
        for (int i = 0; i < m; i++){
            if (l * (s[i].second - 1) >= s[i].first || l * s[i].second < s[i].first){
                flag = false;
            }
        }
        if (flag)
            answer.push_back((n + l - 1) / l);
    }
    if (answer.size() == 0 || (answer.size() > 1 && answer[0] != answer.back())){
        cout << -1 << endl;
        return 0;
    }
    cout << answer[0] << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

bool check(char c){
    return c != 'a' || c != 'u' || c != 'e' || c != 'i' || c != '0';
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        for (int i = 1; i < x / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i <= n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        //freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > s(m);
    for (int i = 0; i < m; i++)
        cin >> s[i].first >> s[i].second;
    vector<int> answer;
    for (int l = 1; l <= n; l++){
        bool flag = true;
        for (int i = 0; i < m; i++){
            if (l * (s[i].second - 1) >= s[i].first || l * s[i].second < s[i].first){
                flag = false;
            }
        }
        if (flag)
            answer.push_back((n + l - 1) / l);
    }
    if (answer.size() == 0 || (answer.size() > 1 && answer[0] != answer.back())){
        cout << -1 << endl;
        return 0;
    }
    cout << answer[0] << endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <time.h>

#define hash nsadasddd
#define prev asdkjajsd
#define next lsdjjbsam
#define rank alsdjjbsa
#define y sandjasdasdd
#define y0 amsdknajdna
#define y1 lmfkansdjsd

using namespace std;

typedef long long ll;
typedef long double dbl;

template <class T>
void print(vector<T> s){
    for (ll i = 0; i < (int)s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}

template <class T>
void print(vector<pair<T, T> > s){
    for (ll i = 0; i < s.size(); i++)
        cout << s[i].first << " " << s[i].second << endl;
    cout << endl;
}

template <class T>
void print(vector<vector<T> > s){
    for (ll i = 0; i < s.size(); i++)
        print(s[i]);
}

int main()
{
    #ifdef ONLINE_JUDGE
        freopen("test.in", "r", stdin);
    #else
        /*freopen("snails.in", "r", stdin);
        freopen("snails.out", "w", stdout);*/
    #endif
    int n, m;
    cin >> n >> m;
    vector<bool> can(1000, true);
    can[0] = false;
    for (int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        for (int i = 1; i < x / k; i++)
            can[i] = false;
        if (k > 1)
            for (int i = (x - 1) / (k - 1) + 1; i < n + 1; i++)
                can[i] = false;
    }
    int answer = -1;
    for (int i = 0; i < n; i++){
        if (can[i] && answer > 0){
            cout << -1 << endl;
            return 0;
        }
        if (can[i]){
            answer = i;
        }
    }
    cout << (n + answer - 1) / answer << endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, int kolk){
  for (int i = 0; i<m; ++i){
    if (nom[i]/kolk <= 0 && nom[i+1]/kolk <= 0){
      return 0;
    }
    cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] != (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }
  }
  cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  int kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
        count = count + 1;
        cout << ' ' << count << ' ';
        if (count > 1){
          cout << -1;
          return 0;
          }
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, double kolk){
  for (int i = 0; i<m; ++i){
     //cout << i << " " << eta[i] << " " << nom[i] <<  "_" << kolk << endl;
     if (ceil(nom[i]/kolk) != eta[i]){
       return 0;
     }

   /*// cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] == (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }*/
  }
  //cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  double kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
        count = count + 1;
       // cout << ' ' << count << ' ';
        if (count > 1){
          cout << -1;
          return 0;
          }
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <iostream>
#include <vector>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, int kolk){
  for (int i = 0; i<m; ++i){
    if (nom[i]/kolk <= 0 && nom[i+1]/kolk <= 0){
      return 0;
    }
   // cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] != (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }
  }
  //cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  int kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
        count = count + 1;
       // cout << ' ' << count << '';
        if (count > 1){
          cout << -1;
          return 0;
          }
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <iostream>
#include <vector>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, int kolk){
  for (int i = 0; i<m; ++i){
    if (nom[i]/kolk <= 0 && nom[i+1]/kolk <= 0){
      return 0;
    }
   // cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] != (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }
  }
  //cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  int kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
        count = count + 1;
       // cout << ' ' << count << ' ';
        if (count > 1){
          cout << -1;
          return 0;
          }
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, double kolk){
  for (int i = 0; i<m; ++i){
     //cout << i << " " << eta[i] << " " << nom[i] <<  "_" << kolk << endl;
     //cout << ceil(nom[i]/kolk) << endl;
     if (ceil(nom[i]/kolk) != eta[i]){
       return 0;
     }

   /*// cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] == (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }*/
  }
  //cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  vector<double> kolkv;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  double kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
      kolkv.push_back(kolk);
       // cout << ' ' << count << ' ';
    }
  }
  /*for (int i = 0; i<kolkv.size(); ++i){
    cout << endl << kolkv[i] << endl;
  }*/
  int y = ceil(n/kolkv[0]);
  for (int i = 0; i<kolkv.size(); ++i){
    if (ceil(n/kolkv[i]) != y){
      cout << "-1";
      return 0;
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <iostream>
#include <vector>
using namespace std;
int gorry (vector<int> nom, vector<int> eta, int m, int kolk){
  for (int i = 0; i<m; ++i){
   // cout << endl << eta[i] << " " << (nom[i]/kolk)<< endl;
    if ((nom[i])%kolk == 0){
    if (eta[i] != (nom[i])/kolk){
      if (nom[i] >= kolk){
      return 0;
      }
    }
  }else if (eta[i] != (nom[i])/kolk+1){
      if (nom[i] >= kolk){
      return 0;
      }
  }
  }
  //cout << kolk << "kkk";
  return 1;
}
int main(){
  int n,m; // номер квартиры и кол-во воспоминаний
  int a,b,abc;
  int count = 0;
  vector <int> nom, eta;
  cin >> n >> m;
  for (int i = 0; i<m; ++i){
    cin >> a >> b;
    nom.push_back(a);
    eta.push_back(b);
  }
  int kolk; //кол-во квартир на этаже
  for (kolk = 1; kolk<=100; ++kolk){
    if (gorry(nom,eta,m, kolk) != 0){
      abc = kolk;
        count = count + 1;
       // cout << ' ' << count << ' ';
        if (count > 1){
          cout << -1;
          return 0;
          }
    }
  }
  if (n%abc != 0){
    cout << (n/abc)+1;
}else{
  cout << n/abc;
}
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int a[103];
int b[103];
int n,m;
vector <int> d;
int main(){
  cin>>n>>m;
  int num=0;
  for (int i=0;i<m;i++)
    cin>>a[i]>>b[i];
  for (int i=1;i<=n;i++){
  	for (int j=0;j<m;j++)
  	  if ((a[j]+i-1) / i == b[j])
	    num++;
	if (num == m) d.push_back(i);
	num=0;
  }
  int chin=0;
  for (int i=1;i<d.size();i++)
    if ((d[i] + n - 1) / d[i] != (d[i-1] + n - 1) / d[i-1])
      chin++;
  if (chin==0) cout<<(n + d[0] - 1) / d[0];
  else cout<<"-1";
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int a[103];
int b[103];
int n,m;
vector <int> d;
int main(){
  cin>>n>>m;
  int num=0;
  for (int i=0;i<m;i++)
    cin>>a[i]>>b[i];
  for (int i=1;i<=n;i++){
  	for (int j=0;j<m;j++)
  	  if ((a[j]+i-1) / i == b[j])
	    num++;
	if (num == m) d.push_back(i);
	num=0;
  }
  int chin=0;
  for (int i=1;i<d.size();i++)
    if (d[i] != d[i-1])
      chin++;
  if (chin==0) cout<<(n + d[0] - 1) / d[0];
  else cout<<"-1";
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int a[103];
int b[103];
int n,m;
vector <int> d;
int main(){
  cin>>n>>m;
  int num=0,biggest=n;
  for (int i=0;i<m;i++)
    cin>>a[i]>>b[i];
  for (int i=0;i<m;i++)
    biggest=max(a[i],biggest);
  for (int i=1;i<=biggest;i++){
  	for (int j=0;j<m;j++)
  	  if ((a[j]+i-1) / i == b[j])
	    num++;
	if (num == m) d.push_back(i);
	num=0;
  }
  int chin=0;
  for (int i=1;i<d.size();i++)
    if ((d[i] + n - 1) / d[i] != (d[i-1] + n - 1) / d[i-1])
      chin++;
  if (chin==0) cout<<(n + d[0] - 1) / d[0];
  else cout<<"-1";
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int a[103];
int b[103];
int n,m;
vector <int> d;
int main(){
  cin>>n>>m;
  int num=0;
  for (int i=0;i<m;i++)
    cin>>a[i]>>b[i];
  for (int i=1;i<=n;i++){
  	for (int j=0;j<m;j++)
  	  if ((a[j]+i-1) / i == b[j])
	    num++;
	if (num == m) d.push_back(i);
	num=0;
  }
  if (d.size()==1) cout<<(n + d[0] - 1) / d[0];
  else cout<<"-1";
  return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	vector<int> g(120,0);
	int i;
	int x, y;

	for (i = 0; i < m; ++i) {
		scanf("%d%d", &x,&y);
		g[x] = y;
	}
	bool f = 1;
	int u,u1;
	for (i = 1; i < 120; ++i) {
		if (g[i] == 0)continue;
		int rt = i - 1, st = i + 1;

		if (g[rt] != 0 && g[rt] != g[i]) {
			f = 0;
			u = rt;
			u1 = g[rt];
			break;
		}

		if (g[st] != 0 && g[st] != g[i]) {
			f = 0;
			u = i;
			u1 = g[i];
			break;
		}
	}
	if (f) {
		cout << -1;
		return 0;
	}
	int rr = u / u1;
	int ee = 0;
	int ans = 0;
	while (ee < n) {
		++ans;
		ee += rr;
	}
	cout << ans;
		return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	vector<int> g(120,0);
	int i;
	int x, y;

	for (i = 0; i < m; ++i) {
		scanf("%d%d", &x,&y);
		g[x] = y;
		if (x == y&&x!=1) {
			cout << n;
			return 0;
		}
	}
	bool f = 1;
	int u,u1;
	for (i = 1; i < 120; ++i) {
		if (g[i] == 0)continue;
		int rt = i - 1, st = i + 1;

		if (g[rt] != 0 && g[rt] != g[i]) {
			f = 0;
			u = rt;
			u1 = g[rt];
			break;
		}

		if (g[st] != 0 && g[st] != g[i]) {
			f = 0;
			u = i;
			u1 = g[i];
			break;
		}
	}
	if (f) {
		cout << -1;
		return 0;
	}
	int rr = u / u1;
	int ee = 0;
	int ans = 0;
	while (ee < n) {
		++ans;
		ee += rr;
	}
	cout << ans;
		return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

void setv(vector<int> &d, int l, int r, int v) {
	int i;
	for (i = l; i <= r; ++i) {
		d[i] = v;
	}
}
int main() {
#ifdef _DEBUG
	freopen("intput.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;
	set<int> var;
	int i;
	int x, y;
	map<int, int> mp;
	for (i = 0; i < k; ++i) {
		cin >> x >> y;
		mp[x] = y;
	}
	int j;

	for (i = 1; i <= 100; ++i) {
		int u = 0;
		vector<int> g(1e5);
		for (j = 0; j < 100; ++j) {
			int l = u + 1;
			u += i;
			setv(g, l, u, j + 1);
		}
		map<int, int>::iterator it;
		bool f = 1;
		for (it = mp.begin(); it != mp.end(); ++it) {
			if (g[it->first] != it->second) {
				f = 0;
				break;
			}
		}
		if (f) {
			var.insert(g[n]);
		}
	}
	if (var.size() == 1||var.size()==0) {
		cout << (*var.begin());
	}
	else {
		cout << "-1";
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	vector<int> g(120,0);
	int i;
	int x, y;

	for (i = 0; i < m; ++i) {
		scanf("%d%d", &x,&y);
		g[x] = y;
		if (x == y&&x!=1) {
			cout << n;
			return 0;
		}
	}
	if (g[n] != 0) {
		cout << g[n];
		return 0;
	}
	bool f = 1;
	int u,u1;
	for (i = 1; i < 120; ++i) {
		if (g[i] == 0)continue;
		int rt = i - 1, st = i + 1;

		if (g[rt] != 0 && g[rt] != g[i]) {
			f = 0;
			u = rt;
			u1 = g[rt];
			break;
		}

		if (g[st] != 0 && g[st] != g[i]) {
			f = 0;
			u = i;
			u1 = g[i];
			break;
		}
	}
	if (f) {
		cout << -1;
		return 0;
	}
	int rr = u / u1;
	int ee = 0;
	int ans = 0;
	while (ee < n) {
		++ans;
		ee += rr;
	}
	cout << ans;
		return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	vector<int> g(120,0);
	int i;
	int x, y;

	for (i = 0; i < m; ++i) {
		scanf("%d%d", &x,&y);
		g[x] = y;
		if (x == y&&x!=1) {
			cout << n;
			return 0;
		}
	}
	bool f = 1;
	int u,u1;
	for (i = 1; i < 120; ++i) {
		if (g[i] == 0)continue;
		int rt = i - 1, st = i + 1;

		if (g[rt] != 0 && g[rt] != g[i]) {
			f = 0;
			u = rt;
			u1 = g[rt];
			break;
		}

		if (g[st] != 0 && g[st] != g[i]) {
			f = 0;
			u = i;
			u1 = g[i];
			break;
		}
	}
	if (f) {
		cout << -1;
		return 0;
	}
	int rr = u / u1;
	int ee = 0;
	int ans = 0;
	while (ee < n) {
		++ans;
		ee += rr;
	}
	cout << ans;
		return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#pragma warning(disable:4996)
#pragma comment(linker,"/STACK:268435456")

void setv(vector<int> &z, int v,int l,int r) {
	int i;
	for (i = l; i <= r; ++i) {
		z[i] = v;
	}
}
int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	vector<int> g(120, 0);
	int i;
	int x, y;

	for (i = 0; i < m; ++i) {
		scanf("%d%d", &x, &y);
		g[x] = y;
		if (x == y&&x != 1) {
			cout << n;
			return 0;
		}
	}
	int re = 0, re1 = 0;
	for (i = 0; i < 120; ++i) {
		if (g[i] == 0)continue;
		if (g[i] == re1) {
			setv(g, re1, re, i);
		}
		re = i;
		re1 = g[i];
	}
	if (g[n] != 0) {
		cout << g[n];
		return 0;
	}
	bool f = 1;
	int u, u1;
	for (i = 1; i < 120; ++i) {
		if (g[i] == 0)continue;
		int rt = i - 1, st = i + 1;

		if (g[rt] != 0 && g[rt] != g[i]) {
			f = 0;
			u = rt;
			u1 = g[rt];
			break;
		}

		if (g[st] != 0 && g[st] != g[i]) {
			f = 0;
			u = i;
			u1 = g[i];
			break;
		}
	}
	if (f) {
		cout << -1;
		return 0;
	}
	int rr = u / u1;
	int ee = 0;
	int ans = 0;
	while (ee < n) {
		++ans;
		ee += rr;
	}
	cout << ans;
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        socks[num]=0;
        l--;
    }

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[1005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    }
    else if (socks[num]==1){
        l--;
}

    if (Max<=l){
        Max=l;
    }
}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<=l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        l--;
}

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ int socks[1002]={0},i,Max=0,n,num,l=0;
cin>>n;

if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<=l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        l--;

    }

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005]={0},i,Max=0,n,num,l=0;
cin>>n;

if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<=l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        l--;

    }

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ int socks[100005]={0},i,Max=0,n,num,l=0;
cin>>n;

if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<=l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        l--;

    }

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    }
    else if (socks[num]==1){
        l--;
}

    if (Max<=l){
        Max=l;
    }
}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<=n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    if (Max<l){
        Max=l;
    }
    }
    else if (socks[num]==1){
        socks[num]=0;
        l--;
    }

}
    cout << Max << endl;
}
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{ long long int socks[100005],i,Max=0,n,num,l=0;
cin>>n;
for(i=0;i<n;i++)
{
    socks[i]=0;
}
if (n==1)
    cout<<1<<endl;
else{
for(i=0; i<n ; i++)
{
    cin>>num;
    if(socks[num]==0)
    {socks[num]=1;
    l++;
    }
    else if (socks[num]==1){
        socks[num]=0;
        l--;
}

    if (Max<l){
        Max=l;
    }
}
    cout << Max << endl;
}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll check(ll a[],ll d,ll b)
{
    ll i;
    for(i=d-1;i>=0;i--)
    {
        if(a[i]==b)
            return 1;
    }
    return 0;
}
int main()
{
    ll n;
    cin>>n;
    ll a[2*n],b,d=1;
    ll c=1,mx=1;
    cin>>a[0];
    ll i;
    for(i=1;i<2*n;i++)
    {
        cin>>b;
        if(check(a,d,b)==1)
        {
            if(c>mx)mx=c;
            c-=1;
        }
        else{
                c++;
            a[d++]=b;
        }
    }
    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll check(ll a[],ll d,ll b)
{
    ll i;
    for(i=d-1;i>=0;i--)
    {
        if(a[i]==b)
            return 1;
    }
    return 0;
}
int main()
{
    ll n;
    cin>>n;
    ll a[2*n],b,d=1;
    ll c=1,mx=1;
    cin>>a[0];
    ll i;
    for(i=1;i<2*n;i++)
    {
        cin>>b;
        if(check(a,d,b)==1)
        {
            mx=max(mx,c);
            c-=1;
        }
        else{
                c++;
            a[d++]=b;
        }
    }
    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
int check(int a[],int d,int b)
{
    int i;
    for(i=d-1;i>=0;i--)
    {
        if(a[i]==b)
            return 1;
    }
    return 0;
}
int main()
{
    int n;
    cin>>n;
    int a[2*n],b,c=1,mx=1,d=1;
    cin>>a[0];
    int i;
    for(i=1;i<2*n;i++)
    {
        cin>>b;
        if(check(a,d,b)==1)
        {
            mx=max(mx,c);
            c-=1;
        }
        else{
                c++;
            a[d++]=b;
        }
    }
    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
int check(int a[],int d,int b)
{
    int i;
    for(i=0;i<d;i++)
    {
        if(a[i]==b)
            return 1;
    }
    return 0;
}
int main()
{
    int n;
    cin>>n;
    int a[2*n],b,c=1,mx=1,d=1;
    cin>>a[0];
    int i;
    for(i=1;i<2*n;i++)
    {
        cin>>b;
        if(check(a,d,b)==1)
        {
            mx=max(mx,c);
            c-=1;
        }
        else{
                c++;
            a[d++]=b;
        }
    }
    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[500000];
int main()
{
    ll n;
    cin>>n;
    ll b,d=1;
    ll c=0,mx=0;
    ll i;
    for(i=0;i<2*n;i++)
    {
        cin>>b;
        if(a[b]==1)
        {
            mx=max(c,mx);
            c-=1;
        }
        else
        {
            c++;
            a[b]++;
        }
    }

    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++) cin>>a[i],b[i]=0;
    for(int i=1;i<n;i++)
    {
        if(b[a[i]]) b[a[i]]=0;
        else b[a[i]]=1;
    }
    for(int i=1;i<n;i++) if(b[i]) ans++;
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0,s;
    cin>>n;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++) cin>>a[i],b[i]=0;
    for(int i=1;i<n;i++)
    {
        s=0;
        if(b[a[i]]) b[a[i]]=0;
        else b[a[i]]=1;
        for(int i=1;i<n;i++) if(b[i]) s++;
        ans=max(ans, s);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long a[100000];
int main()
{
    int n,ans=0,s=0,t;
    cin>>n;
    n*=2;
    for(int i=1;i<=n;i++)
    {
        cin>>t;
        a[t]++;
        if(a[t]==1) s++;
        else s--;
        ans=max(ans, s);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0,s;
    cin>>n;
    int a[2*n+1],b[n+1];
    for(int i=1;i<=2*n;i++) cin>>a[i],b[a[i]]=0;
    for(int i=1;i<=2*n;i++)
    {
        s=0;
        if(b[a[i]]) b[a[i]]=0;
        else b[a[i]]=1;
        for(int i=1;i<=n;i++) if(b[i]) s++;
        ans=max(ans, s);
    }
    cout<<ans;
}


/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = 0;
	int ans[n+2];
	int mx = 0;
	for(int i = 0 ; i < n*2; i++){
		int x;
		cin >> x;
		ans[x] ++;
		if(ans[x] == 2){
			a -= 2;
		}
		else{
			a ++;
		}
		mx = max(a , mx);
	}
	cout << mx;
}


/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;
int ans[1000005];
int main(){
	int n;
	cin >> n;
	int a = 0;
	int mx = 0;
	for(int i = 0 ; i < n*2; i++){
		int x;
		cin >> x;
		ans[x] ++;
		if(ans[x] == 2){
			a -= 2;
		}
		else{
			a ++;
		}
		mx = max(mx , a);
	}
	cout << mx;
}


/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = 0;
	int ans[n+2];
	int mx = 0;
	for(int i = 0 ; i < n*2; i++){
		int x;
		cin >> x;
		ans[x] ++;
		if(ans[x] == 2){
			a -= 2;
		}
		else{
			a ++;
		}
		mx = max(mx , a);
	}
	cout << mx;
}


/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;
int a[1000005] , n;
int main(){
 	int ans = 0, w = 0;
    cin >> n;
    for (int i = 0; i < 2 * n; i++){
        int x;
        cin >> x;
        if (a[x])
            w--;
        else
            w++;
        a[x] ^= 1;
        ans = max(ans, w);
    }
    cout << ans;
}


/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = 0;
	int ans[n+2];
	int mx;
	for(int i = 0 ; i < n*2; i++){
		int x;
		cin >> x;
		ans[x] ++;
		if(ans[x] == 2){
			a -= 2;
		}
		else{
			a ++;
		}
		mx = max(a , mx);
	}
	cout << mx;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;

int a[100090],n;

int main()
{
    while(~scanf("%d",&n))
    {
        int k,sum=0,ma=0;
        memset(a,0,sizeof a);
        for(int i=1;i<=2*n;i++)
        {
            scanf("%d",&k);
            if(a[k]) a[k]--,sum--;
            else sum++,ma=max(sum,ma),a[k]++;
        }
        printf("%d\n",ma);
    }
    return 0;
}


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

int main ()
{
	int n,cnt=0,res=0;

	cin>>n;
	int arr[n]={};
	for(int i=0;i<n*2;i++)
	{
		cin>>arr[i];
	}

		for(int i=0;i<n;i++)
	{
		if(arr[i]!=arr[i+1])
		{
			cnt++;
		}
		else if(arr[i]==arr[i+1])
		{
			res=cnt+1;
			cnt=0;
		}
		if(cnt>res)
		{
			res=cnt;
		}
	}
		cout<<res<<endl;
    return 0;
}


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

int main ()
{
	int n,cnt=0,res=0;
	int arr[100001]={};
	cin>>n;

	for(int i=0;i<n*2;i++)
	{
		cin>>arr[i];
	}

		for(int i=0;i<n;i++)
	{
		if(arr[i]!=arr[i+1])
		{
			cnt++;
		}
		else if(arr[i]==arr[i+1])
		{
			res=cnt+1;
			cnt=0;
		}
		if(cnt>res)
		{
			res=cnt;
		}
	}
		cout<<res<<endl;
    return 0;
}


#include <iostream>
#include<algorithm>
#include <string>
#include<vector>
using namespace std;
int main ()
{

int n;
cin>>n;
vector<int>v;
int cnt=0,nu,res=0;

for(int i=0;i<n*2;i++)
{
	cin>>nu;
	v.push_back(nu);
}
for(int i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	{
		cnt++;
	}
	else if(v[i]==v[i+1])
	{
		cnt++;
		if(res<cnt)
			res=cnt;

		cnt==0;

	}
	if(res<cnt)
			res=cnt;
}

cout<<res;

return 0;
}


#include <iostream>
#include<algorithm>
#include <string>
#include<vector>
using namespace std;
int main ()
{

int n;
cin>>n;
vector<int>v;
int cnt=0,nu,res=0;

for(int i=0;i<n*2;i++)
{
	cin>>nu;
	v.push_back(nu);
}
for(int i=0;i<n;i++)
{
	if(v[i]!=v[i+1])
	{
		cnt++;
	}
	else if(v[i]==v[i+1])
	{
		cnt++;
		if(res<cnt)
			res=cnt;

		cnt==0;

	}
}

cout<<res;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main(){

        int32_t n,count=0,temp=0,b;
        cin>>n;
        int32_t a[n];
        for(int i=0; i<2*n; i++){
            cin>>b;

            if(a[b-1]!=1){

                a[b-1]=1;
                //cout<<b<<"\t";
                count++;
                //cout<<"\t"<<count<<"\n";
            }
            else if(a[b-1]==1){
                a[b-1]=0;
                //cout<<"\t"<<count<<"\t"<<temp<<"\n";
                if(temp<count){
                    temp =count;
                }
                count--;

            }
        }
        cout<<temp<<"\n";
}


#include<bits/stdc++.h>

using namespace std;
int main(){

        int32_t n,count=0,temp=0,b;
        cin>>n;
        int32_t a[n]={0};
        for(int i=0; i<2*n; i++){
            cin>>b;

            if(a[b-1]!=1){

                a[b-1]=1;
                count++;
            }
            else if(a[b-1]==1){
                a[b-1]=0;
                count--;
            }
            if(temp<=count){
                    temp = count;
                }

        }
        cout<<temp<<"\n";
}


#include<bits/stdc++.h>

using namespace std;
int main(){

        int32_t n,count=0,temp=0,b;
        cin>>n;
        int32_t a[n]={0};
        for(int i=0; i<2*n; i++){
            cin>>b;

            if(a[b-1]!=1){

                a[b-1]=1;
                count++;
            }
            else if(a[b-1]==1){
                a[b-1]=0;
                count--;
                //cout<<"\t"<<count<<"\t"<<temp<<"\n";

            }
            if(temp<=count){
                    temp = count;
                }

        }
        cout<<temp<<"\n";
}


#include<bits/stdc++.h>

using namespace std;
int main(){

        int n,a,count=0,k;
        vector<int> v;
        cin>>n;
        vector<int>::iterator it;
        for(int i=0; i<2*n; i++){
            cin>>a;
            it = find(v.begin(),v.end(),a);
            if(it != v.end()){
                //cout<<a<<"hi\t";
                //cout<<v.size()<<"\t";
                v.erase(it);
                //cout<<v.size()<<"\t";
            }
            else{
                //cout<<a<<"\t";
                v.push_back(a);

            }
            int w=v.size();
            if(w >count){
                count= v.size();
            }
        }
        cout<<count<<"\n";
}


#include<bits/stdc++.h>

using namespace std;
int main(){

        int n,count=0,k,temp=0,b;
        cin>>n;
        int a[n];
        vector<int>::iterator it;
        for(int i=0; i<2*n; i++){
            cin>>b;
            if(a[b]!=1){
                a[b]=1;
                count++;
            }
            else if(a[b]==1){
                a[b]=0;
                if(temp<count){
                    temp =count;
                }
                count--;

            }
        }
        cout<<temp<<"\n";
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
const int MAXN = 200000 + 10;
const int INF = 1e9 + 7;
int a[MAXN];
int vis[MAXN] = { 0 };
int main() {
    int n;
    while (scanf("%d", &n)!=EOF) {
        int cnt = 0;
        int MAX = 0;
        for (int i = 0; i < 2*n; i++) {
            scanf("%d", a + i);
            if (vis[a[i]]) {
                cnt--;
            }
            else {
                cnt++;
                vis[a[i]] = 1;
            }
            MAX = max(MAX, cnt);
        }
        printf("%d\n", MAX);
    }
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(ll n){
    if(n<2)
    return false;
    if(n==2)
    return true;
    if(n%2==0)
    return false;
    for(int i=3;i*i<=n;i=i+2){
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    int a[n],cnt=0,m=0,k=0;
    for(int i=0;i<2*n;i++){
        int x;
        cin>>x;
        int temp=0;
        for(int j=0;j<k;j++){
            if(x==a[j]){
            cnt--;
            temp=1;
            break;
            }
        }
            if(temp==0){
                cnt++;
                a[k]=x;
                k++;
            }
        m=max(cnt,m);
    }
    cout<<m;
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(ll n){
    if(n<2)
    return false;
    if(n==2)
    return true;
    if(n%2==0)
    return false;
    for(int i=3;i*i<=n;i=i+2){
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    int a[2*n]={0},cnt=0,m=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
        if(a[x]==2){
            cnt--;
        }
        else
        cnt++;
        m=max(m,cnt);
    }
    cout<<m;
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(ll n){
    if(n<2)
    return false;
    if(n==2)
    return true;
    if(n%2==0)
    return false;
    for(int i=3;i*i<=n;i=i+2){
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    ll n;
    cin>>n;
    ll a[n],cnt=0,m=0,k=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        int temp=0;
        for(int j=0;j<k;j++){
            if(x==a[j]){
            cnt--;
            temp=1;
            break;
            }
        }
            if(temp==0){
                cnt++;
                a[k]=x;
                k++;
            }
        m=max(cnt,m);
    }
    cout<<m;
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(ll n){
    if(n<2)
    return false;
    if(n==2)
    return true;
    if(n%2==0)
    return false;
    for(int i=3;i*i<=n;i=i+2){
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    int a[2*n]={0},cnt=0,m=0;
    for(int i=0;i<2*n;i++){
        int x;
        cin>>x;
        a[x]++;
        if(a[x]==2){
            cnt--;
        }
        else
        cnt++;
        m=max(m,cnt);
    }
    cout<<m;
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(ll n){
    if(n<2)
    return false;
    if(n==2)
    return true;
    if(n%2==0)
    return false;
    for(int i=3;i*i<=n;i=i+2){
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    int a[n],cnt=0,m=0,k=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        int temp=0;
        for(int j=0;j<k;j++){
            if(x==a[j]){
            cnt--;
            temp=1;
            break;
            }
        }
            if(temp==0){
                cnt++;
                a[k]=x;
                k++;
            }
        m=max(cnt,m);
    }
    cout<<m;
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)
using namespace std;
bool used[99999];
unsigned long long n,x,y,m,c,a[99999],sum;
main ()
{
	cin >> n;
	FOR(i,1,n*2)
	{
		cin >> a[i];
	}
	FOR(i,1,n*2)
	{
		c=max(c,sum);
		if(!used[a[i]])
		{
			sum++;
			used[a[i]]=1;
		}
		else
		{
			sum--;
		}
	}
	cout << c;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)
using namespace std;
bool used[99999];
unsigned long long n,x,y,m,c,a[99999],sum;
main ()
{
	cin >> n;
	FOR(i,1,n*2)
	{
		cin >> a[i];
	}
	FOR(i,1,n*2)
	{
		if(!used[a[i]])
		{
			sum++;
			used[a[i]]=1;
		}
		else
		{
			sum--;
		}
		c=max(c,sum);
	}
	cout << c;
}


/*#inclulde<somebrains>*/
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<stack>
#include<deque>
#include<vector>
#include<cstring>

// *******************************************************************************

#define FOR(i, a, b) for(int i = a; i <= b; ++	i)
#define rFOR(i, a, b) for(int i = b; i >= a; --i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)

// *******************************************************************************

using namespace std;
vector<int> v;
bool u[11111];
unsigned long long a[111111],n,sum,ans,m,cnt;
main()
{
	cin >> m;
	n = 2*m;
	FOR(i,1,n)
	{
		cin >> a[i];
	}
	FOR(i,1,n)
	{
		if(!u[a[i]])
		{
			u[a[i]]=1;
			sum++;
			cnt = max(cnt,sum);
		}
		else if(u[a[i]])
		{
			sum--;
		}
	}
	cout << cnt;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)
using namespace std;
bool used[111111];
unsigned long long n,x,y,m,c,a[111111],sum;
main ()
{
	cin >> n;
	FOR(i,1,n*2)
	{
		cin >> a[i];
	}
	FOR(i,1,n*2)
	{
		if(!used[a[i]])
		{
			sum++;
			used[a[i]]=1;
		}
		else
		{
			sum--;
		}
		c=max(c,sum);
	}
	cout << c;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)
using namespace std;
bool used[11111];
unsigned long long n,x,y,m,c,a[11111],sum;
main ()
{
	cin >> n;
	FOR(i,1,n*2)
	{
		cin >> a[i];
	}
	FOR(i,1,n*2)
	{
		if(!used[a[i]])
		{
			sum++;
			used[a[i]]=1;
		}
		else
		{
			sum--;
		}
		c=max(c,sum);
	}
	cout << c;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define mxel(a, b) *max_element(a+1, a+b+1)
#define mnel(a, b) *min_element(a+1, a+b+1)
using namespace std;
bool used[99999];
unsigned long long n,x,y,m,c,a[99999],sum;
main ()
{
	cin >> n;
	FOR(i,1,n*2)
	{
		cin >> a[i];
	}
	FOR(i,1,n*2)
	{
		if(!used[a[i]])
		{
			sum++;
			used[a[i]]=1;
			c=max(c,sum);
		}
		else
		{
			sum--;
		}
	}
	cout << c;
}


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

int main()
{
	int a;
	cin >> a;
	int b = a * 2;
	int arr[100000] = { 0 };
	int max_count = 0;
	bool check = true;
	for (int i = 0, j = 0; i < b; i++)
	{
		cin >> arr[i];
		for (j = 0; j < i && arr[i] != arr[j]; j++);
		if (j<i)
		{
			arr[i] = 0;
			arr[j] = arr[i - 1];
			arr[i - 1] = 0;
			i -= 2;
			b -= 2;
			check = false;
		}
		if (check) max_count++;
		else check = true;
	}
	cout << max_count;
}


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

int main() {
	int a;
	cin >> a;
	int b = a * 2;
	int arr[100000];
	int max_count =1;
	for (int i = 0,k=0; i < b; i++)
	{
		cin >> arr[i];
		for (int j = 0; j<i; j++)
		{
			if (arr[i] == arr[j]) {
				arr[i] = 0;
				arr[j] = arr[i-1];
				i -= 2;
				b -= 2;
				break;
			}
		}
		for (int j = 0; j < i; j++)
			if (arr[j])k++;
		if (k > max_count) {
			max_count = k;
			k = 0;
		}
	}
	cout << max_count;
	return 0;
}


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

int main() {
	int a;
	cin >> a;
	int b = a * 2;
	int arr[100000];
	int max_count =1;
	for (int i = 0,k=0; i < b; i++)
	{
		cin >> arr[i];
		for (int j = 0; j<i; j++)
		{
			if (arr[i] == arr[j]) {
				arr[i] = 0;
				arr[j] = arr[i-1];
				i -= 2;
				b -= 2;
				break;
			}
		}
		for (int j = 0; j < i*2; j++)
		{
			if (arr[k])k++;
		}
		if (k > max_count) {
			max_count = k;
			k = 0;
		}
	}
	cout << max_count;
	return 0;
}


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

int main()
{
	int a;
	cin >> a;
	int b = a * 2;
	int n=0;
	int arr[100000] = { 0 };
	int max_count = 0;
	bool check = true;
	for (int i = 0, j = 0; i < b; i++)
	{
		cin >> arr[i];
		for (j = 0; j < i && arr[i] != arr[j]; j++);
		if (j<i)
		{
			arr[j] = arr[i - 1];
			i -= 2;
			b -= 2;
			max_count--;
			check = false;
		}
		if (check) {
			max_count++;
			if (max_count > n)n = max_count;
		}
		else check = true;
	}
		cout << n;
}


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

int main()
{
	int a;
	cin >> a;
	int b = a * 2;
	int n=0;
	int arr[100000] = { 0 };
	int max_count = 0;
	bool check = true;
	for (int i = 0, j = 0; i < b; i++)
	{
		cin >> arr[i];
		for (j = 0; j < i && arr[i] != arr[j]; j++);
		if (j<i)
		{
			arr[i] = 0;
			arr[j] = arr[i - 1];
			arr[i - 1] = 0;
			i -= 2;
			b -= 2;
			max_count--;
			check = false;
		}
		if (check) {
			max_count++;
			if (max_count > n)n = max_count;
		}
		else check = true;
	}
		cout << n;
}


#include <iostream>
using namespace std;
int main() {
	int arr[100001] = { 0 };
	int a; cin >> a;
	int b=0;
	int c=0, d=0;
	for (int i = 1; i <=a*2 ; i++)
	{
		cin >> b;
		arr[b]++;
		if (arr[b]==1)c++;
		else c--;
		if (c > d)d = c;
	}
	cout << d;
}


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

int main() {
	int a;
	cin >> a;
	int b = a * 2;
	int arr[100000];
	int max_count = 1;
	for (int i = 0, k = 0; i < b; i++)
	{
		cin >> arr[i];
		for (int j = 0; j<i; j++)
		{
			if (arr[i] == arr[j]) {
				arr[i] = 0;
				arr[j] = arr[i - 1];
				arr[i - 1] = 0;
				i -= 2;
				b -= 2;

				break;
			}
		}
		for (int j = 0; j <= i; j++)
			if (arr[j] != 0) {
				 k++;
			}
		if (k > max_count) {

			max_count = k;
		}
		k = 0;
	}
	cout << max_count;
	return 0;
}


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

int main() {
	int a;
	cin >> a;
	int arr[100000]={ 0 };
	int max_count =1;
	for (int i = 0,k=0; i < a*2; i++)
	{
		cin >> arr[i];
		for (int j = 0; j <= i*2; j++)
		{
			if (arr[i] == arr[j] && i != j) {
				arr[i] = 0;
				arr[j] = 0;
				break;
			}
		}
		for (int j = 0; j < i*2; j++)
		{
			if (arr[k])k++;
		}
		if (k > max_count) {
			max_count = k;
			k = 0;
		}
	}
	cout << max_count;
	return 0;
}


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

int main() {
	int a;
	cin >> a;
	int arr[100000]={ 0 };
	int max_count =0;
	for (int i = 0,k=0; i < a*2; i++)
	{
		cin >> arr[i];
		for (int j = 0; j <= i*2; j++)
		{
			if (arr[i] == arr[j] && i != j) {
				arr[i] = 0;
				arr[j] = 0;
				break;
			}
		}
		for (int j = 0; j < i*2; j++)
		{
			if (arr[k])k++;
		}
		if (k > max_count) {
			max_count = k;
			k = 0;
		}
	}
	cout << max_count;
	return 0;
}


#include <algorithm>
#include <iostream>

#define FOR(i,n) for (int i = 0; i < n; ++i)

#define VI vector<int>
#define VB vector<bool>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int nbPaires;
    cin >> nbPaires;
    VB paires(nbPaires+1, false);
    int onTable = 0;
    int maxTable = 0;
    FOR (i, 2*nbPaires) {
        int chaussette;
        cin >> chaussette;
        if (paires[chaussette]) {
            paires[chaussette] = false;
            onTable -= 1;
        } else {
            paires[chaussette] = true;
            onTable += 1;
            maxTable = max(onTable, maxTable);
        }
    }
    cout << maxTable << "\n";
}


#include <algorithm>
#include <cstdio>

#define FOR(i,n) for (int i = 0; i < n; ++i)

#define VI vector<int>
#define VB vector<bool>

using namespace std;

int main() {
    int nbPaires;
    scanf("%d", &nbPaires);
    VB paires(nbPaires+1, false);
    int onTable = 0;
    int maxTable = 0;
    FOR (i, 2*nbPaires) {
        int chaussette;
        scanf("%d", &chaussette);
        if (paires[chaussette]) {
            onTable -= 1;
        } else {
            paires[chaussette] = true;
            onTable += 1;
            maxTable = max(onTable, maxTable);
        }
    }
    printf("%d\n", maxTable);
}


#include <algorithm>
#include <cstdio>
#include <vector>

#define FOR(i,n) for(int i=0; i<n; ++i)

#define VI vector<int>
#define VB vector<bool>

using namespace std;

int main() {
    int nbPaires;
    scanf("%d", &nbPaires);
    VB paires(nbPaires+1, false);
    int onTable = 0;
    int maxTable = 0;
    FOR(i, 2*nbPaires) {
        int chaussette;
        scanf("%d", &chaussette);
        if (paires[chaussette]) {
            onTable -= 1;
        } else {
            paires[chaussette] = true;
            onTable += 1;
            maxTable = max(onTable, maxTable);
        }
    }
    printf("%d\n", maxTable);
}


#include <algorithm>
#include <cstdio>

#define FOR(i,n) for(int i=0; i<n; ++i)

#define VI vector<int>
#define VB vector<bool>

using namespace std;

int main() {
    int nbPaires;
    scanf("%d", &nbPaires);
    VB paires(nbPaires+1, false);
    int onTable = 0;
    int maxTable = 0;
    FOR(i, 2*nbPaires) {
        int chaussette;
        scanf("%d", &chaussette);
        if (paires[chaussette]) {
            onTable -= 1;
        } else {
            paires[chaussette] = true;
            onTable += 1;
            maxTable = max(onTable, maxTable);
        }
    }
    printf("%d\n", maxTable);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,n,a,b,c = 0,len,sum = 0, gap = 0, total = 0, maxx = 1;
    bool gate = 1;
    vector<int>vec;

    cin >> n;

    for(i=0; i<n*2; i++){
        cin>> a;
        gate = 1;

        len = vec.size();
        for(j=0; j<len; j++){
            if(a == vec[j]){
                //cout<<a<<"A"<<j+1<<"C"<<c<<endl;

                if(maxx<c)
                    maxx = c;

                //vec[j] = -1;
                vec.erase(vec.begin()+j);
                c--;
                gate = 0;

                break;
            }

        }
        if(gate == 1){
            c++;
            vec.push_back(a);
        }

    }
    cout<<maxx<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,n,a,b,c = 0,len,sum = 0, gap = 0, total = 0, maxx = 1;
    bool gate = 1;
    vector<int>vec;

    cin >> n;

    for(i=0; i<n*2; i++){
        cin>> a;
        gate = 1;

        len = vec.size();
        for(j=0; j<len; j++){
            if(a == vec[j]){
                //cout<<a<<"A"<<j+1<<"C"<<c<<endl;

                if(maxx<c)
                    maxx = c;

                vec[j] = -1;
                c--;
                gate = 0;

                break;
            }

        }
        if(gate == 1){
            c++;
            vec.push_back(a);
        }

    }
    cout<<maxx<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,n,a,b,c = 0,len,sum = 0, gap = 0, total = 0, maxx = 0;
    bool gate = 1;

    cin >> n;
    int shocks[n];
    memset(shocks,0,sizeof(shocks));
    for(i=0; i<n*2; i++){
        cin>> a;
        if(shocks[a-1]==0){
            shocks [a-1]= 1;
            c++;
            if(c>maxx)
                maxx = c;
        }else if(shocks[a-1]==1){
            shocks [a-1]= 0;
            c--;
        }
    }
    cout<<maxx<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,n,a,b,c = 0,len,sum = 0, gap = 0, total = 0, maxx = 0;
    bool gate = 1;

    cin >> n;
    int shocks[n];
    memset(shocks,0,sizeof(shocks));
    for(i=0; i<n*2; i++){
        cin>> a;
        if(shocks[a-1]==0){
            shocks [a-1]= 1;
            c++;
            if(c>maxx)
                maxx = c;
        }else if(shocks[a-1]==1){
            shocks [a-1]= 2;
            c--;
        }
    }
    cout<<maxx<<endl;

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e6 + 7;

bool used[mxn];

using namespace std;

int main (){

    Brom4ik

    ll n, a[mxn], mx = 0, ans = 0;
    cin >> n;
    for (int i = 1; i <= n * 2; i ++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i ++){
        if (used[a[i]] == 0){
            used[a[i]] = 1;
            ans ++;
        }else {
            used[a[i]] = 0;
            ans --;
        }
        mx = max(ans, mx);
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e6 + 7;

bool used[mxn];

using namespace std;

int main (){

    Brom4ik

    ll n, a[mxn], mx = 0, ans = 0;
    cin >> n;
    for (int i = 1; i <= n * 2; i ++){
        cin >> a[i];
    }
    for (int i = 1; i <= n * 2; i ++){
        if (used[a[i]] == 0){
            used[a[i]] = 1;
            ans ++;
        }else {
            used[a[i]] = 0;
            ans --;
        }
        mx = max(ans, mx);
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e5 + 7;

bool used[mxn];

using namespace std;

int main (){

    Brom4ik

    ll n, a[mxn], mx = 0;
    cin >> n;
    for (int i = 1; i <= n * 2; i ++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i ++){
        if (used[i] == 0){
            used[i] = 1;
            a[i] --;
        }else {
            a[i] ++;
        }
        mx = max(a[i], mx);
    }
    cout << mx + 1;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e6 + 7;

bool used[mxn];

using namespace std;

int main (){

    Brom4ik

    ll n, a[mxn], mx = 0;
    cin >> n;
    for (int i = 1; i <= n * 2; i ++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i ++){
        if (used[i] == 0){
            used[i] = 1;
            a[i] --;
        }else {
            a[i] ++;
        }
        mx = max(a[i], mx);
    }
    cout << mx + 1;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e5 + 7;

using namespace std;

int main (){

    Brom4ik

    ll n, a[mxn], cnt = 0, sum = 0;
    cin >> n;
    for (int i = 1; i<= n; i ++){
        cin >> a[i];
    }
    for (int i = 1; i<= n; i ++){
        if (a[i] != a[i + 1]){
            cnt ++;
        }
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a,s,x,i,n;
set <int> q;
main(){
    cin>>n;
    for (i=0; i<2*n; i++){
        cin>>a;
        s=q.size();
        q.insert(a);
    if (x<q.size()) x=q.size();
    if (s==q.size()) q.erase(a);

    }cout<<x;
}


#include <bits/stdc++.h>
using namespace std;
int q,a,s,x,i;
set <int> q;
main(){
    cin>>n;
    for (i=0; i<2*n; i++){
        cin>>a;
        s=q.size();
        q.insert(a);
    if (x<q.size()) x=q.size();
    if (s==q.size()) q.erase(a);

    }
}cout<<x;


#include <bits/stdc++.h>
using namespace std;
int a,s,x,i;
set <int> q;
main(){
    cin>>n;
    for (i=0; i<2*n; i++){
        cin>>a;
        s=q.size();
        q.insert(a);
    if (x<q.size()) x=q.size();
    if (s==q.size()) q.erase(a);

    }
}cout<<x;


#include <bits/stdc++.h>
using namespace std;
int a,s,x,i;
set <int> q;
main(){
    cin>>n;
    for (i=0; i<2*n; i++){
        cin>>a;
        s=q.size();
        q.insert(a);
    if (x<q.size()) x=q.size();
    if (s==q.size()) q.erase(a);

    }cout<<x;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	set < int > q;

	int n;
	scanf("%d", &n);
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (q.count(x) == 1) {
			q.insert(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
		else {
			q.erase(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int flag[222222];
	for (int i = 0; i < 222222; i++) flag[i] = 0;
	int n;
	scanf("%d", &n);
	int ans = -1;
	int cur = 0;
	for (int i = 0; i < 2 * n; i++) {
		int x;
		scanf("%d", &x);
		if (flag[x] == 0) {
			flag[x] = 1;
			cur++;
			ans = max (ans, cur);
		}
		else {
			flag[x] = 0;
			cur--;
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	set < int > q;
	int n;
	scanf("%d", &n);
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if(q.count(x) != 0) {
				q.insert(x);
			    ans = max(ans, q.size());
			}
		}
		else {
			q.erase(x);
			ans = max (ans, q.size());
		}
		return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	set < int > q;

	int n;
	scanf("%d", &n);
	int ans = -1;
	for (int i = 0; i < 2 * n; i++) {
		int x;
		scanf("%d", &x);
		if (q.count(x) != 0) {
			q.erase(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
		else {
			q.insert(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int flag[111111];
	int n;
	scanf("%d", &n);
	int ans = -1;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (flag[x] == 0) {
			q.insert(x);
			cur++;
			ans = max (ans, cur);
		}
		else {
			flag[x] = 0;
			cur--;
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	set < int > q;
	int n;
	scanf("%d", &n);
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if(q.count(x) != 0) {
				q.insert(x);
				int k = q.size();
			    ans = max(ans, k);
			}
		}
		else {
			q.erase(x);
			int k = q.size();
			ans = max (ans, k);
		}
		printf("%d\n", ans);
		return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	set < int > q;

	int n;
	scanf("%d", &n);
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (q.count(x) != 0) {
			q.erase(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
		else {
			q.insert(x);
			int cur = q.size();
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int flag[111111];
	for (int i = 0; i < 111111; i++) flag[i] = 0;
	int n;
	scanf("%d", &n);
	int ans = -1;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (flag[x] == 0) {
			flag[x] = 1;
			cur++;
			ans = max (ans, cur);
		}
		else {
			flag[x] = 0;
			cur--;
			ans = max (ans, cur);
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define pp pop_back
#define ll long long
#define r_0 return 0
#define pb push_back
#define pf push_front
#define ld long double
#define TIME ios_base::sync_with_stdio(0)
#define loves(s) freopen( s, "r", stdin )
#define cookies(s) freopen( s, "w", stdout )

const ll N = 1e9;

using namespace std;

    ll n, m, k, x, y, cnt;
    vector<ll>v, v1;
    bool f = false;

int main(){
    TIME;
    cin >> n;
    for ( int i = 1; i <= n * 2; i ++ ){
        cin >> x;
        v.pb( x );
    }
    for ( int i = 0; i < v.size(); i ++ ){
        x = v[i];
        f = false;
        for ( int j = 0; j < v1.size(); j ++ ){
            if ( x == v1[j] ){
                v1.erase( v1.begin() + j );
                f = true;
                break;
            }
        }
        if ( f == false )
            v1.pb( x );
        y = v1.size();
        cnt = max( cnt, y );
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define pp pop_back
#define ll long long
#define r_0 return 0
#define pb push_back
#define pf push_front
#define ld long double
#define TIME ios_base::sync_with_stdio(0)
#define loves(s) freopen( s, "r", stdin )
#define cookies(s) freopen( s, "w", stdout )

const ll N = 1e9;

using namespace std;

    ll n, m, k, x, y, cnt;
    ll used[1001], t[100001];
    vector<ll>v, v1;

int main(){
    TIME;
    cin >> n;
    for ( int i = 1; i <= n * 2; i ++ ){
        cin >> x;
        v.pb( x );
    }
    v1.pb( v[0] );
    for ( int i = 0; i < v.size(); i ++ ){
        x = v[i];
        for ( int j = 0; j < v1.size(); j ++ ){
            if ( x == v1[j] ){
                v.erase( v.begin() + j );
                break;
            }
            else
                v1.pb( x );
        }
        y = v1.size();
        cnt = max( cnt, y );
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define fr first
#define se second
#define pp pop_back
#define ll long long
#define r_0 return 0
#define pb push_back
#define pf push_front
#define ld long double
#define TIME ios_base::sync_with_stdio(0)
#define loves(s) freopen( s, "r", stdin )
#define cookies(s) freopen( s, "w", stdout )

const ll N = 1e9;

using namespace std;

    ll n, m, k, x, y, cnt;
    bool used[1001];

int main(){
    TIME;
    cin >> n;
    for ( int i = 1; i <= n * 2; i ++ ){
        cin >> x;
        if ( used[x] != 1 )
            used[x] = 1, cnt ++;
        else
            used[x] = 0, cnt --;
        k = max( k, cnt );
    }
    cout << k;
}
/*
 █████╗ ███╗   ███╗██╗██████╗ ██████╗ ███████╗██╗  ██╗
██╔══██╗████╗ ████║██║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝
███████║██╔████╔██║██║██████╔╝██████╔╝█████╗  █████╔╝
██╔══██║██║╚██╔╝██║██║██╔══██╗██╔══██╗██╔══╝  ██╔═██╗
██║  ██║██║ ╚═╝ ██║██║██║  ██║██████╔╝███████╗██║  ██╗
╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝  ╚═╝╚═════╝ ╚══════╝╚═╝  ╚═╝
*/


#include<bits/stdc++.h>
#define fr first
#define se second
#define pp pop_back
#define ll long long
#define r_0 return 0
#define pb push_back
#define pf push_front
#define ld long double
#define TIME ios_base::sync_with_stdio(0)
#define loves(s) freopen( s, "r", stdin )
#define cookies(s) freopen( s, "w", stdout )

const ll N = 1e9;

using namespace std;

    ll n, m, k, x, y, cnt;
    bool used[100001];

int main(){
    TIME;
    cin >> n;
    for ( int i = 1; i <= n * 2; i ++ ){
        cin >> x;
        if ( used[x] != 1 )
            used[x] = 1, cnt ++;
        else
            used[x] = 0, cnt --;
        k = max( k, cnt );
    }
    cout << k;
}
/*
 █████╗ ███╗   ███╗██╗██████╗ ██████╗ ███████╗██╗  ██╗
██╔══██╗████╗ ████║██║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝
███████║██╔████╔██║██║██████╔╝██████╔╝█████╗  █████╔╝
██╔══██║██║╚██╔╝██║██║██╔══██╗██╔══██╗██╔══╝  ██╔═██╗
██║  ██║██║ ╚═╝ ██║██║██║  ██║██████╔╝███████╗██║  ██╗
╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝  ╚═╝╚═════╝ ╚══════╝╚═╝  ╚═╝
*/


#include<bits/stdc++.h>
#define fr first
#define se second
#define pp pop_back
#define ll long long
#define r_0 return 0
#define pb push_back
#define pf push_front
#define ld long double
#define TIME ios_base::sync_with_stdio(0)
#define loves(s) freopen( s, "r", stdin )
#define cookies(s) freopen( s, "w", stdout )

const ll N = 1e9;

using namespace std;

    ll n, m, k, x, y, cnt;
    bool used[1001];

int main(){
    TIME;
    cin >> n;
    for ( int i = 1; i <= n * 2; i ++ ){
        cin >> x;
        if ( used[x] != 1 )
            used[x] = 1, cnt ++;
        else
            used[x] = 0, cnt --;
        x = max( x, cnt );
    }
    cout << x;
}
/*
 █████╗ ███╗   ███╗██╗██████╗ ██████╗ ███████╗██╗  ██╗
██╔══██╗████╗ ████║██║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝
███████║██╔████╔██║██║██████╔╝██████╔╝█████╗  █████╔╝
██╔══██║██║╚██╔╝██║██║██╔══██╗██╔══██╗██╔══╝  ██╔═██╗
██║  ██║██║ ╚═╝ ██║██║██║  ██║██████╔╝███████╗██║  ██╗
╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝  ╚═╝╚═════╝ ╚══════╝╚═╝  ╚═╝
*/


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    short arr [100002] ;
    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val-1]==0 ){
            s++;
            arr[val-1]++;
            maxi = max(maxi,s);
        }
        else
            s--;
    }
    cout << maxi;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    short arr [100000] ;
    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val]==0 ){
            s++;
            arr[val]++;
            maxi = max(maxi,s);
        }
        else
            s--;
    }
    cout << maxi;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    short arr [100002] = {0} ;
    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val-1]==0 ){
            s++;
            arr[val-1]=1;
            maxi = max(maxi,s);
        }
        else if ( arr[val-1]==1 ){
            s--;
        }
    }
    cout << maxi;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    short arr [100000] ;
    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val-1]==0 ){
            s++;
            arr[val-1]++;
            maxi = max(maxi,s);
        }
        else
            s--;
    }
    cout << maxi;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{

    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    short arr [n] = {0} ;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val-1]==0 ){
            s++;
            arr[val-1]=1;
            maxi = max(maxi,s);
        }
        else if ( arr[val-1]==1 ){
            s--;
        }
    }
    cout << maxi;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    short arr [100000] = {0} ;
    int n(0);
    int val;
    int s(0);
    int maxi(0);
    cin >> n;
    for (int i = 0; i<2*n;i++){
        cin >> val;
        if ( arr[val-1]==0 ){
            s++;
            arr[val-1]++;
            maxi = max(maxi,s);
        }
        else
            s--;
    }
    cout << maxi;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0;
cin>>n;
set<int>a;
for(int i=0;i<2*n;i++)
{
   int x;
   cin>>x;
   if(a.count(x))
   {
      a.erase(x);
   }
  else
   {
    a.insert(x) ;
    }
ans=max(ans,(a.size());
}
cout<<ans;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,ans=0;
cin>>n;
set<int>a;
for(int i=0;i<2*n;i++)
{
   cin>>x;
   if(a.count(x))
   {
      a.erase(x);
   }
  else
   {
    a.insert(x) ;
    }
ans=max(ans,a.size());
}
cout<<ans;
return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<long long, pair<vector<int>, int> > cache;

pair<vector<int>, int> solve(long long h, int n, int a, int b)
{
	if (cache.count(h) > 0)
		return cache[h];

	if (h == 0) {
		cache[h] = make_pair(vector<int>(n, 0), 0);
		return cache[h];
	}

	pair<vector<int>, int> best;
	best.second = 1000000;

	for (int i = 1; i < n - 1; i++) {
		long long t = h;
		long long c = min((long long) a, (t >> (i * 4)) %0x10);
		long long l = min((long long) b, (t >> ((i - 1) * 4)) % 0x10);
		long long r = min((long long) b, (t >> ((i + 1) * 4)) % 0x10);
		if (c || l || r) {
			t -= (c << (i * 4)) + (l << ((i - 1) * 4)) + (r << ((i + 1) * 4));
			pair<vector<int>, int> x = solve(t, n, a, b);
			if (x.second + 1 < best.second) {
				best.first = x.first;
				best.first[i]++;
				best.second = x.second + 1;
			}
		}
	}

	cache[h] = best;
	return best;
}

int main(int argc, char *argv[])
{
	int n, a, b, x;
	vector<int> h;

	cin >> n >> a >> b;
	h.resize(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];

	long long t = 0;
	for (int i = 0; i < n; i++)
		t = (t << 4) + h[i] + 1;

	pair<vector<int>, int> r = solve(t, n, a, b);

	cout << r.second << endl;
	bool first = true;
	for (int i = 0; i < r.first.size(); i++)
		for (int j = 0; j < r.first[i]; j++) {
			if (!first) cout << " ";
			cout << i + 1;
			first = false;
		}
	cout << endl;

	return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int cnt;
vector<int> ans;

void dfs(int curr, int step, int a, int b, vector<int> &h, vector<int> &w)
{
    int n = h.size();
    if (curr == n - 1) {
        if (h[n - 2] >= 0) return;
        int c = h[n - 1] >= 0 ? h[n - 1] / b + 1 : 0;
        if (step + c < cnt) {
            cnt = step + c;
            ans = w;
            ans[n - 2] += c;
        }
    } else if (h[curr - 1] >= 0) {
        int c = h[curr - 1] / b + 1;
        h[curr - 1] -= c * b;
        h[curr] -= c * a;
        h[curr + 1] -= c * b;
        w[curr] += c;
        dfs(curr, step + c, a, b, h, w);
        h[curr - 1] += c * b;
        h[curr] += c * a;
        h[curr + 1] += c * b;
        w[curr] -= c;
    } else {
        dfs(curr + 1, step, a, b, h, w);
        if (h[curr] >= 0) {
            h[curr] -= a;
            h[curr + 1] -= b;
            w[curr]++;
            dfs(curr, step + 1, a, b, h, w);
            h[curr] += a;
            h[curr + 1] += b;
            w[curr]--;
        }
    }
}

int main(int argc, char *argv[])
{
    int n, a, b;
    vector<int> h;

    cin >> n >> a >> b;
    h.resize(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    ans.resize(n, 0);

    cnt = 100000000;
    vector<int> w(n, 0);
    dfs(1, 0, a, b, h, w);

    cout << cnt << endl;
    for (int i = 0; i < ans.size(); i++)
        for (int j = 0; j < ans[i]; j++)
            cout << i + 1 << " ";
    cout << endl;

    return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<long long, pair<vector<int>, int> > cache;

pair<vector<int>, int> solve(long long h, int n, long long a, long long b)
{
    if (cache.count(h) > 0)
        return cache[h];

    if (h == 0) {
        cache[h] = make_pair(vector<int>(n, 0), 0);
        return cache[h];
    }

    pair<vector<int>, int> best;
    best.second = 1000000;

    for (int k = 1; k < n - 1; k++) {
        int i = k - 1 == 0 ? n - 2 : k - 1;
        long long t = h;
        long long c = min(a, (t >> (i * 5)) % 0x20);
        long long l = min(b, (t >> ((i - 1) * 5)) % 0x20);
        long long r = min(b, (t >> ((i + 1) * 5)) % 0x20);
        if (c || l || r) {
            t -= (c << (i * 5)) + (l << ((i - 1) * 5)) + (r << ((i + 1) * 5));
            pair<vector<int>, int> x = solve(t, n, a, b);
            if (x.second + 1 < best.second) {
                best.first = x.first;
                best.first[i]++;
                best.second = x.second + 1;
            }
        }
    }

    cache[h] = best;
    return best;
}

int main(int argc, char *argv[])
{
    int n, a, b, x, m = 0, n1 = 0, n2 = 0;
    vector<int> h;

    cin >> n >> a >> b;
    h.resize(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    vector<int> ans(n, 0);

    while (h[0] >= 0) {
        h[0] -= min(b, h[0] + 1);
        h[1] -= min(a, h[1] + 1);
        h[2] -= min(b, h[2] + 1);
        ans[1]++;
        m++;
    }
    while (h[n - 1] >= 0) {
        h[n - 1] -= min(b, h[n - 1] + 1);
        h[n - 2] -= min(a, h[n - 2] + 1);
        h[n - 3] -= min(b, h[n - 3] + 1);
        ans[n - 2]++;
        m++;
    }

    /*
    for (int i = 1; i < n - 1; i++) {
        while (h[i - 1] > 2 * a && h[i] > 2 * a && h[i + 1] > 2 * a) {
            h[i - 1] -= b;
            h[i] -= a;
            h[i + 1] -= b;
            ans[i]++;
            m++;
        }
    }
    */

    long long t = 0;
    for (int i = 0; i < n; i++)
        t = (t << 5) + h[n - i - 1] + 1;

    pair<vector<int>, int> r = solve(t, n, a, b);

    cout << r.second + m << endl;

    for (int i = 0; i < r.first.size(); i++)
        ans[i] += r.first[i];

    for (int i = 0; i < ans.size(); i++)
        for (int j = 0; j < ans[i]; j++)
            cout << i + 1 << " ";
    cout << endl;

    return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<vector<int>, pair<vector<int>, int> > cache;

pair<vector<int>, int> solve(const vector<int> &h, int a, int b)
{
    if (cache.count(h) > 0)
        return cache[h];

    bool done = true;
    for (int i = 0; i < h.size(); i++)
        if (h[i] >= 0) {
            done = false;
            break;
        }

    if (done) {
        cache[h] = make_pair(vector<int>(h.size(), 0), 0);
        return cache[h];
    }

    pair<vector<int>, int> best;
    best.second = 1000000;

    vector<int> t = h;
    for (int i = 1; i < h.size() - 1; i++) {
        int c = min(a, t[i] + 1);
        int l = min(b, t[i - 1] + 1);
        int r = min(b, t[i + 1] + 1);
        if (c || l || r) {
            t[i] -= c;
            t[i - 1] -= l;
            t[i + 1] -= r;

            pair<vector<int>, int> x = solve(t, a, b);
            if (x.second + 1 < best.second) {
                best.first = x.first;
                best.first[i]++;
                best.second = x.second + 1;
            }

            t[i] += c;
            t[i - 1] += l;
            t[i + 1] += r;
        }
    }

    cache[h] = best;
    return best;
}

int main(int argc, char *argv[])
{
    int n, a, b, x;
    vector<int> h;

    cin >> n >> a >> b;
    h.resize(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    pair<vector<int>, int> r = solve(h, a, b);

    cout << r.second << endl;
    bool first = true;
    for (int i = 0; i < r.first.size(); i++)
        for (int j = 0; j < r.first[i]; j++) {
            if (!first) cout << " ";
            cout << i + 1;
            first = false;
        }
    cout << endl;

    return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<long long, pair<vector<int>, int> > cache;

pair<vector<int>, int> solve(long long h, int n, long long a, long long b)
{
    if (cache.count(h) > 0)
        return cache[h];

    if (h == 0) {
        cache[h] = make_pair(vector<int>(n, 0), 0);
        return cache[h];
    }

    pair<vector<int>, int> best;
    best.second = 1000000;

    for (int k = 1; k < n - 1; k++) {
        int i = k - 1 == 0 ? n - 2 : k - 1;
        long long t = h;
        long long c = min(a, (t >> (i * 5)) % 0x20);
        long long l = min(b, (t >> ((i - 1) * 5)) % 0x20);
        long long r = min(b, (t >> ((i + 1) * 5)) % 0x20);
        if (c || l || r) {
            t -= (c << (i * 5)) + (l << ((i - 1) * 5)) + (r << ((i + 1) * 5));
            pair<vector<int>, int> x = solve(t, n, a, b);
            if (x.second + 1 < best.second) {
                best.first = x.first;
                best.first[i]++;
                best.second = x.second + 1;
                if ((k == 1 && r > 0) || (k == n - 2 && l > 0))
                    break;
            }
        }
    }

    cache[h] = best;
    return best;
}

int main(int argc, char *argv[])
{
    int n, a, b, x, n1 = 0, n2 = 0;
    vector<int> h;

    cin >> n >> a >> b;
    h.resize(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    long long t = 0;
    for (int i = 0; i < n; i++)
        t = (t << 5) + h[n - i - 1] + 1;

    pair<vector<int>, int> r = solve(t, n, a, b);

    cout << r.second << endl;
    bool first = true;
    for (int i = 0; i < r.first.size(); i++)
        for (int j = 0; j < r.first[i]; j++) {
            if (!first) cout << " ";
            cout << i + 1;
            first = false;
        }
    cout << endl;

    return 0;
}


// D. Lizards and Basements 2
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<long long, pair<vector<int>, int> > cache;

pair<vector<int>, int> solve(long long h, int n, long long a, long long b)
{
    if (cache.count(h) > 0)
        return cache[h];

    if (h == 0) {
        cache[h] = make_pair(vector<int>(n, 0), 0);
        return cache[h];
    }

    pair<vector<int>, int> best;
    best.second = 1000000;

    for (int k = 1; k < n - 1; k++) {
        int i = k - 1 == 0 ? n - 2 : k - 1;
        long long t = h;
        long long c = min(a, (t >> (i * 5)) % 0x20);
        long long l = min(b, (t >> ((i - 1) * 5)) % 0x20);
        long long r = min(b, (t >> ((i + 1) * 5)) % 0x20);
        if (c || l || r) {
            t -= (c << (i * 5)) + (l << ((i - 1) * 5)) + (r << ((i + 1) * 5));
            pair<vector<int>, int> x = solve(t, n, a, b);
            if (x.second + 1 < best.second) {
                best.first = x.first;
                best.first[i]++;
                best.second = x.second + 1;
            }
        }
    }

    cache[h] = best;
    return best;
}

int main(int argc, char *argv[])
{
    int n, a, b, x, m = 0, n1 = 0, n2 = 0;
    vector<int> h;

    cin >> n >> a >> b;
    h.resize(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];

    vector<int> ans(n, 0);

    while (h[0] >= 0) {
        h[0] -= min(b, h[0] + 1);
        h[1] -= min(a, h[1] + 1);
        h[2] -= min(b, h[2] + 1);
        ans[1]++;
        m++;
    }
    while (h[n - 1] >= 0) {
        h[n - 1] -= min(b, h[n - 1] + 1);
        h[n - 2] -= min(a, h[n - 2] + 1);
        h[n - 3] -= min(b, h[n - 3] + 1);
        ans[n - 2]++;
        m++;
    }

    for (int i = 1; i < n - 1; i++) {
        while (h[i - 1] >= b && h[i] >= a && h[i + 1] >= b) {
            h[i - 1] -= b;
            h[i] -= a;
            h[i + 1] -= b;
            ans[i]++;
            m++;
        }
    }

    long long t = 0;
    for (int i = 0; i < n; i++)
        t = (t << 5) + h[n - i - 1] + 1;

    pair<vector<int>, int> r = solve(t, n, a, b);

    cout << r.second + m << endl;

    for (int i = 0; i < r.first.size(); i++)
        ans[i] += r.first[i];

    bool first = true;
    for (int i = 0; i < ans.size(); i++)
        for (int j = 0; j < ans[i]; j++) {
            if (!first) cout << " ";
            cout << i + 1;
            first = false;
        }
    cout << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define mod 1000000007
#define N 100005

int fm,ft;
vector<int> fs;

void go(int n, int a, int b, int m, int h[], vector<int> s)
{
    if(m==fm)
    {
        if(ft>h[n])
        {
            ft = h[n];
            if(fs.size()<s.size())
                fs.resize(s.size());
            for(int i=0;i<s.size();i++)
                fs[i] = s[i];
        }
        return;
    }

    int hh[n+1];
    for(int i=0;i<=n;i++)
        hh[i] = h[i];

    for(int i=1;i<n-1;i++)
    {
        if(!(m&(1<<i)))
        {
            int tm = m;
            vector<int> ss = s;
            int x = h[i]/a+1;
            hh[i] = 0;

            tm|=(1<<i);
            if(i==1 || h[i-1]<b*x)
            {
                tm|=(1<<(i-1));
                x=max(x,h[i-1]/b+1);
                hh[i-1] = 0;
            }
            if(i==n-2 || h[i+1]<b*x)
            {
                tm|=(1<<(i+1));
                x=max(x,h[i+1]/b+1);
                hh[i+1] = 0;
            }
            hh[n]=h[n]+x;
            while(x--)  ss.push_back(i);
            go(n,a,b,tm,hh,ss);

            hh[i] = h[i];
            hh[i-1] = h[i-1];
            hh[i+1] = h[i+1];
        }
    }
}

int main()
{
    int i,n,a,b,h[11];

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

    for(i=0;i<n;i++)
        fm|=(1<<i);

    ft = INT_MAX;
    vector<int> s;
    go(n,a,b,0,h,s);
    cout<<ft<<endl;
    for(i=0;i<fs.size();i++)
        cout<<fs[i]+1<<' ';
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define mod 1000000007
#define N 100005

int h[20];
int n,a,b,st[100];

bool dfs(int t, int l, int r)
{
    if(t==0)
    {
        for(int i=0;i<n;i++)
            if(h[i]>=0) return 0;
        return 1;
    }

    if(h[l]<0)  return dfs(t,l+1,r);

    if(l==n-1)
    {
        st[t] = n-1;
        h[l]-=b;
        if(dfs(t-1,l,r))    return 1;
        h[l]+=b;
    }
    else
    {
        for(int i=max(l,r);i<=l+1;i++)
            if(i>0 && i<n-1)
            {
                h[i]-=a;
                h[i-1]-=b;
                h[i+1]-=b;

                st[t] = i+1;
                if(dfs(t-1,l,i))    return 1;

                h[i]+=a;
                h[i-1]+=b;
                h[i+1]+=b;
            }

    }
    return 0;
}

int main()
{
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++)
        scanf("%d",&h[i]);
    int ans = 1;
    while(1)
    {
        if(dfs(ans,0,1))
        {
            printf("%d\n",ans);
            for(int i=1;i<=ans;i++)  printf("%d ",st[i]);
            return 0;
        }
        ans++;
    }
    return 0;
}


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

#define LL long long
#define mod 1000000007

int a[9000000],b[9000000];
vector<vector<int> > mp;
int rs[3001][3001],ts[3001][3001];

void dijk(int s, int d[])
{
    for(int i=0;i<=3000;i++)
        d[i] = -1;
    set<pair<int,int> > st;
    d[s] = 0;
    st.insert(make_pair(d[s],s));

    while(!st.empty())
    {
        int u = st.begin()->second;
        int w = st.begin()->first;
        st.erase(st.begin());
        for(int i=0;i<mp[u].size();i++)
        {
            int v = mp[u][i];

            if(d[v]==-1 || d[v]>w+rs[u][v])
            {
                if(d[v]!=-1)    st.erase(make_pair(d[v],v));
                d[v] = w+rs[u][v];
//                cout<<d[v]<<' '<<rs[u][v]<<endl;
                st.insert(make_pair(d[v],v));
            }
        }
    }
}

int main()
{
    int t,n,i,rr,tt,s,d,m;
    int d1[3001],d2[3001];
    cin>>t;
    while(t--)
    {
        mp.clear();
        cin>>n>>m;
        mp.resize(n+1);
        for(i=0;i<m;i++)
        {
            cin>>a[i]>>b[i]>>rr>>tt;
            mp[a[i]].push_back(b[i]);
            mp[b[i]].push_back(a[i]);
            rs[a[i]][b[i]] = rs[b[i]][a[i]] = rr;
            ts[a[i]][b[i]] = ts[b[i]][a[i]] = tt;
        }
        cin>>s>>d;

        dijk(s,d1);
        dijk(d,d2);

        int ans = d1[d];
        for(i=0;i<m;i++)
        {
            int t = min(d1[a[i]]+d2[b[i]],d2[a[i]]+d1[b[i]])+ts[a[i]][b[i]];
            ans = min(ans,t);
        }
        cout<<ans<<endl;
    }
    return 0;
}