#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7;
const double BI = acos(-1), EPS = 1e-12;
int n, p, l, r;
double ans, arr[N][2];
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &l, &r);
    arr[i][1] = r / p - (l - 1) / p;
    arr[i][0] = r - l + 1 - arr[i][1];
  }
  for (int i = 0; i < n; ++i) {
    ans += 2.0 *
           (arr[i][1] * arr[(i + 1) % n][0] + arr[i][1] * arr[(i + 1) % n][1] +
            arr[i][0] * arr[(i + 1) % n][1]) /
           (arr[i][0] + arr[i][1]) /
           (arr[(i + 1) % n][0] + arr[(i + 1) % n][1]);
  }
  printf("%.12f", 1000.0 * ans);
  return 0;
}
