#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cout << setprecision(9);
  long long n, p;
  cin >> n >> p;
  long long a[n], b[n], l[n], r[n], t[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    a[i] = r[i] / p - l[i] / p;
    if (l[i] % p == 0) a[i]++;
    t[i] = r[i] - l[i] + 1;
    b[i] = t[i] - a[i];
  }
  double ans = 0.0;
  double num, deno;
  for (int i = 0; i < (n - 1); i++) {
    num = (double)(t[i] * t[i + 1] - b[i] * b[i + 1]);
    deno = (double)(t[i] * t[i + 1]);
    ans = ans + num / deno;
  }
  num = (double)(t[0] * t[n - 1] - b[0] * b[n - 1]);
  deno = (double)(t[0] * t[n - 1]);
  ans = ans + num / deno;
  ans = ans * 2000.0;
  printf("%.9lf\n", ans);
}
