#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int l[N], r[N], p;
double eval(int i) {
  double n = r[i] - l[i] + 1;
  double x = r[i] / p - l[i] / p + (l[i] % p == 0);
  return x / n;
}
int main() {
  int n;
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    double pb1 = eval(i);
    double pb2 = eval((i + 1) % n);
    ans += 2000.0 * (pb1 + pb2 - pb1 * pb2);
  }
  cout << setprecision(6) << fixed << ans;
}
