#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const int mod = 1e9 + 7;
double pt[maxn];
int main() {
  int n, p;
  cin >> n >> p;
  int l, r;
  double s = 0;
  for (int i = 0; i <= n - 1; i++) {
    cin >> l >> r;
    pt[i] = (r / p - (l - 1) / p) * 1.0 / (r - l + 1);
    s += pt[i];
  }
  double ans = 4000 * s;
  for (int i = 0; i <= n - 1; i++) ans -= 2000 * pt[i] * pt[(i + 1) % n];
  printf("%.8f\n", ans);
  return 0;
}
