#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
int n, p;
vector<int> l, r, mas;
double f(int i) {
  double c = r[i] - l[i] + 1 - mas[i];
  double z = r[i] - l[i] + 1;
  return c / z;
}
int main() {
  cin >> n >> p;
  l.resize(n + 1);
  r.resize(n + 1);
  mas.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    mas[i] = r[i] / p - (l[i] - 1) / p;
  }
  double res = 0;
  for (int i = 1; i <= n; i++) {
    int j = i + 1;
    if (j == n + 1) j = 1;
    res += (1 - f(i) * f(j));
  }
  res *= 2000;
  printf("%6f\n", res);
  return 0;
}
