#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
const int INF = 1000000010;
const int mod = 1000003;
int n, p;
double ar[MAXN];
int main() {
  double res = 0;
  scanf(" %d %d", &n, &p);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf(" %d %d", &a, &b);
    int k = b / p - (a - 1) / p;
    ar[i] = (double)k / (b - a + 1);
  }
  for (int i = 0; i < n; i++) {
    int a, b, c;
    b = i;
    a = (i - 1 + n) % n;
    c = (i + 1) % n;
    double temp = ar[b] * 2 + (1 - ar[b]) * ar[a] * ar[c] * 2 +
                  (1 - ar[b]) * ar[a] * (1 - ar[c]) +
                  (1 - ar[b]) * ar[c] * (1 - ar[a]);
    res += temp * 1000;
  }
  printf("%.12lf\n", res);
  return 0;
}
