#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long l[maxn], r[maxn];
int p;
long long cal(int i) {
  long long ret = 0;
  if (l[i] % p == 0) ret = 1;
  return ret + r[i] / p - l[i] / p;
}
int main() {
  int n;
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &l[i], &r[i]);
  }
  double res = 0;
  for (int i = 0; i < n; i++) {
    long long c1 = cal(i), a1 = r[i] - l[i] + 1;
    long long c2 = cal((i + 1) % n), a2 = r[(i + 1) % n] - l[(i + 1) % n] + 1;
    long long num = c1 * a2 + c2 * a1 - c1 * c2;
    res += 1.0 * num / (1.0 * a1 * a2);
  }
  res = res * 1000 * 2;
  printf("%.6f\n", res);
  return 0;
}
