#include <bits/stdc++.h>
using namespace std;
void solve(long long N, long long M, vector<long long> l, vector<long long> r) {
  for (long long d = 1; d <= 1; d++) {
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
      long long len = r[i] - l[i] + 1;
      if (len >= d) {
        ans++;
      } else {
        long long j = d;
        while (j <= M) {
          if (l[i] <= j && j <= r[i]) {
            ans++;
            break;
          }
          j += d;
        }
      }
    }
    cout << ans << endl;
  }
}
int main() {
  long long M;
  long long N;
  scanf("%lld", &N);
  vector<long long> l(N - 1 + 1);
  vector<long long> r(N - 1 + 1);
  scanf("%lld", &M);
  for (int i = 0; i <= N - 1; i++) {
    scanf("%lld", &l[i]);
    scanf("%lld", &r[i]);
  }
  solve(N, M, l, r);
  return 0;
}
