#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, p;
  cin >> n >> p;
  long long l, r;
  double var = 1;
  double m = 0;
  vector<double> pr(n);
  vector<double> dl(n);
  double ostl, ostr;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    var *= (r - l + 1);
    dl[i] = r - l + 1;
    ostl = l % p;
    ostr = r % p;
    if (ostl != 0) l = l + p - ostl;
    r = r - ostr;
    pr[i] = (r - l) / p + 1;
  }
  for (int i = 1; i < n - 1; i++) {
    m += 2 * pr[i] / dl[i] + (1 - pr[i] / dl[i]) * pr[i + 1] / dl[i + 1] +
         (1 - pr[i] / dl[i]) * pr[i - 1] / dl[i - 1];
  }
  m += 2 * pr[0] / dl[0] + (1 - pr[0] / dl[0]) * pr[1] / dl[1] +
       (1 - pr[0] / dl[0]) * pr[n - 1] / dl[n - 1];
  m += 2 * pr[n - 1] / dl[n - 1] + (1 - pr[n - 1] / dl[n - 1]) * pr[0] / dl[0] +
       (1 - pr[n - 1] / dl[n - 1]) * pr[n - 2] / dl[n - 2];
  printf("%.6f", m * 1000.0);
  return 0;
}
