#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T& n) {
  char ch;
  int sign = 1;
  while (!isdigit(ch = getchar()))
    if (ch == '-') sign = -1;
  n = ch - '0';
  while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
  n *= sign;
}
const int INF = 1e9 + 7;
const int N = 122222;
int n, p;
int l[N], r[N], sum[N];
int main() {
  read(n), read(p);
  for (int i = (1); i <= (n); ++i) {
    read(l[i]), read(r[i]);
    sum[i] = r[i] / p - (l[i] - 1) / p;
    sum[i] = r[i] - l[i] + 1 - sum[i];
  }
  double ans = 0.0;
  for (int i = (1); i <= (n); ++i) {
    int j = i % n + 1;
    double t = 1. * sum[i] / (r[i] - l[i] + 1) * sum[j] / (r[j] - l[j] + 1);
    ans += 1 - t;
  }
  printf("%.6lf\n", ans * 2000);
  return 0;
}
