#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  set<long long> s;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    s.insert(x);
    s.insert(y);
  }
  vector<long long> dp(n, -1);
  function<long long(long long)> solve = [&](long long val) {
    if (val == n) return 1LL;
    if (val > n) return 0LL;
    long long &ans = dp[val];
    if (ans != -1) return ans;
    ans = 0;
    for (auto it = s.begin(); it != s.end(); it++) {
      ans += solve(val + *it);
    }
    return ans;
  };
  long long ans = solve(1);
  cout << ans << '\n';
  return 0;
}
