#include <algorithm>
#include <iostream>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cmath>
#include <climits>
#include <queue>
#include <bitset>
#include <set>
#include <assert.h>
#include <map>
using namespace std;
typedef vector<vector<long> > dim2veclo;
typedef vector<vector<int> > dim2vecin;
typedef vector<vector<double> > dim2vecdo;
typedef vector<vector<long long> > dim2vecll;
typedef vector<int> vecin;
typedef vector<long> veclo;
typedef vector<double> vecdo;
typedef vector<long long> vecll;
typedef vector<bool> vecbo;
typedef vector<vector<bool> > dim2vecbo;
typedef long long ll;
typedef vector < pair<ll, ll> > vecpa;
typedef vector<string> vecst;
typedef pair<ll, ll> pail;
typedef pair<int, int> pain;
typedef vector<vecpa > dim2vecpa;


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

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

vecpa black;
ll res = 1;
vecbo isOK;
ll n, m;
ll now = n;
vector<pair<ll, bool>> nw;

bool solve(pail hoge) {
    ll Y = hoge.second;
    if (isOK[Y]) {
        if (Y == 0) {
            if (!isOK[Y + 1]) {
                nw.push_back(make_pair(Y, false));
                res--;
            }
        }
        else if (Y == 2 * n) {
            if (!isOK[Y - 1]) {
                nw.push_back(make_pair(Y, false));
                res--;
            }
        }
        else if (!isOK[Y - 1] && !isOK[Y + 1]) {
            nw.push_back(make_pair(Y, false));
            res--;
        }
        return true;
    }
    else {
        if (Y != 2 * n && isOK[Y + 1]) {
            nw.push_back(make_pair(Y, true));
            res++;
        }
        else if (Y != 0 && isOK[Y - 1]) {
            nw.push_back(make_pair(Y, true));
            res++;
        }
        return true;
    }
}

int main() {
    cin >> n >> m;
    black = vecpa(m);
    isOK = vecbo(2 * n + 1, false);
    rep(i, m) {
        ll x, y; cin >> x >> y;
        black[i] = make_pair(x, y);
    }
    sort(black.begin(), black.end(), [](pail a, pail b) {
        if (a.first != b.first) return a.first < b.first;
        return abs(n - a.second) < abs(n - b.second);
        });

    isOK[n] = true;
    rep(i, m) {
        solve(black[i]);
        if (i < m - 1 && black[i].first == black[i + 1].first) continue;
        rep(j, nw.size()) {
            isOK[nw[j].first] = nw[j].second;
        }
        nw = vector<pair<ll, bool>>();
    }
    cout << res;

    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {

long long int  n,i,j,x,y,z,k,z1,c1=0,sum=0,c=0,d,m,x1,y1,x2,y2;
string o,p;
cin>>o>>p;
for(i=0;i<o.size();i++)
{
sum=sum+(o[i]-'0');
}
for(i=0;i<p.size();i++)
{
c=c+(p[i]-'0');
}
cout<<max(c,sum);

return 0;
}
