#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
using namespace std;
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i > -1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// using lll=boost::multiprecision::cpp_int;
// using
// Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ // x^nをmodで割った余り

  if (p != -1)
  {
    x = (x % p + p) % p;
  }
  ll ret = 1;
  while (n > 0)
  {
    if (n & 1)
    {
      if (p != -1)
        ret = (ret * x) % p;
      else
        ret *= x;
    }
    if (p != -1)
      x = (x * x) % p;
    else
      x *= x;
    n >>= 1;
  }
  return ret;
}

struct myrand{
  random_device seed;
  mt19937 mt;
  myrand():mt(seed()){}
  int operator()(int a,int b){//[a,b)
    uniform_int_distribution<int>dist(a,b-1);
    return dist(mt);
  }
};

// using namespace atcoder;

//------------------------
//------------------------
//------------------------
//------------------------
//------------------------

using P=pair<int,int>;
void solve()
{
  int n,m;
  cin>>n>>m;
  vector<int>x(m),y(m);
  map<int,int>mp;
  rep(i,m){
    cin>>x[i]>>y[i];
    if(!mp.count(x[i])){
      mp[x[i]]=mp.size();
    }
  }
  vector<set<int>>row(mp.size()+5);
  rep(i,m){
    row[mp[x[i]]].emplace(y[i]);
  }
  unordered_set<int>ans;
  ans.emplace(n);
  for(auto &e:mp){
    set<int>add,sub;
    for(auto &ee:row[e.se]){
      if(ans.count(ee-1)||ans.count(ee+1)){
        add.emplace(ee);
      }else if(ans.count(ee)){
        sub.emplace(ee);
      }
    }
    for(auto &ee:sub)ans.erase(ee);
    for(auto &ee:add)ans.emplace(ee);
  }
  cout<<ans.size()<<"\n";
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define ppll pair<ll,pair<ll,ll>>
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,i;
    cin>>n>>x;
    char str[n+1]={'\0'};
    cin>>str;
    for(i=0;i<strlen(str);i++)
    {
    	if(str[i]=='o')
    	{
    		x++;
    	}
    	else 
    	{
    		if(x!=0)
    		{
    			x--;
    		}
    	}
    }
    cout<<x<<"\n";
	return 0;
}