#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define endl '\n'
ll n,m;
vector <P> v,w;
set<ll> s;
int main(){
    cin >> n >> m;
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        v.emplace_back(x,y);
    }
    sort(v.begin(),v.end());
    s.insert(n);
    int l=0,r;
    while(l<m){
        vector <ll> a,b;
        r=l;
        while(r<m){
            if(v[r].first==v[l].first)r++;
            else break;
        }
        for(int i=l;i<r;i++){
            int x=v[i].second;
            if((s.find(x-1)!=s.end())||(s.find(x+1)!=s.end()))a.push_back(x);
            if(((s.find(x-1)==s.end())&&(s.find(x+1)==s.end())) && (s.find(x)!=s.end()))b.push_back(x);
        }
        rep(i,a.size())s.insert(a[i]);
        rep(i,b.size())s.erase(b[i]);
        l=r;
    }
    cout << s.size() << endl;
    return 0;
}



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

int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i=0;i<n;i++) cin >> a[i];
  vector<vector<long long>> dp(n,vector<long long>(2,0));
  vector<long long> mins(n);
  long long nx = x;
  for (int i=n-1;i>=0;i--) {
    mins[i] = nx/a[i];
    nx -= mins[i]*a[i];
  }
  dp[0][0] = 1;
  if (n > 1 && mins[0] != 0) {
    dp[0][1] = 1;
  }
  for (int i=1;i<n-1;i++) {
    dp[i][0] = dp[i-1][0];
    if (mins[i]+1 != a[i+1]/a[i]) {
      dp[i][0] += dp[i-1][1];
    }
    dp[i][1] = dp[i-1][1];
    if (mins[i] != 0) {
      dp[i][1] += dp[i-1][0];
    }
  }
  if (n > 1) {
    dp[n-1][0] = dp[n-2][0]+dp[n-2][1];
  }
  /*for (int i=0;i<n;i++) {
    cout << dp[i][0] << ' ';
  }
  cout << endl;
  for (int i=0;i<n;i++) {
    cout << dp[i][1] << ' ';
  }
  cout << endl;*/
  cout << dp[n-1][0] << endl;
}
