#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
long long n, p;
long long l[100005], r[100005], g[100005], b[100005];
long double ans;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    g[i] = r[i] / p - (l[i] - 1) / p;
    b[i] = r[i] - l[i] + 1 - g[i];
  }
  for (long long i = 1; i <= n - 1; i++)
    ans +=
        (long double)((g[i] + b[i]) * (g[i + 1] + b[i + 1]) - b[i] * b[i + 1]) *
        1000.0 / (long double)(g[i] + b[i]) /
        (long double)(g[i + 1] + b[i + 1]);
  ans += (long double)((g[n] + b[n]) * (g[1] + b[1]) - b[n] * b[1]) * 1000.0 /
         (long double)(g[n] + b[n]) / (long double)(g[1] + b[1]);
  cout << fixed << setprecision(6) << ans * 2 << endl;
  return 0;
}
