//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.
 
#ifdef local
#include <bits/extc++.h>
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(args...) qqbx(#args, args)
using ost = std::ostream;
#define DESTL(STL, BEG, END, OUT) \
    template <typename ...T> ost& operator<<(ost &O, std::STL<T...> v) { int f=0; for(auto x: v) O << (f++ ? ", " : BEG) << OUT; return O << END; }
DESTL(deque, "[", "]", x); DESTL(vector, "[", "]", x);
DESTL(set, "{", "}", x); DESTL(multiset, "{", "}", x); DESTL(unordered_set, "{", "}", x);
DESTL(map , "{", "}", x.first << ":" << x.second); DESTL(unordered_map , "{", "}", x.first << ":" << x.second);
template <typename U, typename V> ost& operator<<(ost &O, std::pair<U,V> p) { return O << '(' << p.first << ',' << p.second << ')'; }
template <typename T, size_t N> ost& operator<<(ost &O, std::array<T,N> a) { int f=0; for(T x: a) O << (f++ ? ", " : "[") << x; return O << "]"; }
template <typename T, size_t ...I> ost& prtuple(ost &O, T t, std::index_sequence<I...>) { return (..., (O << (I ? ", " : "(") << std::get<I>(t))), O << ")"; }
template <typename ...T> ost& operator<<(ost &O, std::tuple<T...> t) { return prtuple(O, t, std::make_index_sequence<sizeof...(T)>()); }
template <typename ...T> void qqbx(const char *s, T ...args) {
    int cnt = sizeof...(T);
    (std::cerr << "\033[1;32m(" << s << ") = (" , ... , (std::cerr << args << (--cnt ? ", " : ")\033[0m\n")));
}
#else
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) int(lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)
 
using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 100025, INF = 1e18, MOD = 998244353, K = 19, inf = 1e7;
constexpr inline ll cdiv(ll x, ll m) { return x/m + (x%m ? (x<0) ^ (m>0) : 0); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

int dp[3001][3001][2];
int vis[3001][3001][2];
int DP(int n, int k, bool first) {
    if(k == 0 || n == 0) return n == 0 && k == 0;
    if(k > n) return 0;
    if(vis[n][k][first]) return dp[n][k][first];
    vis[n][k][first] = true;
    int &ans = dp[n][k][first];
    return ans = (DP(n-1, k-1, false) + DP(n, k*2, true)) % MOD;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    cout << DP(n, k, true) << '\n';
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<lint,lint> P;
const bool debugFlag=true;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  map<P,int> st;
  rep(i,m){
    lint a,b;cin>>a>>b;
    st[{b,a}]=3;
    if(st.find({b-1,a-1})==st.end())st[{b-1,a-1}]=0;
    if(st.find({b,a-1})==st.end())st[{b,a-1}]=0;
    if(st.find({b+1,a-1})==st.end())st[{b+1,a-1}]=0;
    st[{b-1,a-1}]=max(st[{b-1,a-1}],1);
    st[{b,a-1}]=max(st[{b,a-1}],2);
    st[{b+1,a-1}]=max(st[{b+1,a-1}],1);
  }
  vector<int> status;
  int cur=0;
  st[{n,0}]=3;
  vector<vector<int>> edge(st.size());
  int start=-1;
  for(auto& val:st){
    status.push_back(val.second);
    val.second=cur++;
  }
  for(auto& [p,no]:st){
    auto& [y,x]=p;
    if(y==n&&x==0)start=no;
    auto it=st.find({y+1,x+1});
    if(it!=st.end()){
      if(status[it->second]==3)edge[no].push_back(it->second);
    }
    it=st.find({y-1,x+1});
    if(it!=st.end()){
      if(status[it->second]==3)edge[no].push_back(it->second);
    }
    it=st.upper_bound({y,x});
    if(it==st.end())continue;
    if(it->first.first==y&&it->first.second>x){
      if(status[it->second]<=2)edge[no].push_back(it->second);
    }
  }
  queue<int> que;
  que.push(start);
  vector<int> ok(edge.size(),0);
  ok[start]=1;
  while(!que.empty()){
    int buf=que.front();que.pop();
    for(auto& e:edge[buf]){
      if(ok[e]==0){
        ok[e]=1;
        que.push(e);
      }
    }
  }
  set<int> res;
  for(auto& [p,no]:st){
    if(ok[no]&&status[no]%2==1){
      auto it=st.upper_bound(p);
      if(it==st.end()){
        res.insert(p.first);
      }
      else if(it->first.first!=p.first){
        res.insert(p.first);
      }
    }
  }
  cout<<res.size()<<"\n";
  return 0;
}