#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  long long p;
  long double pd;
  long double a[100005];
  long double ld[100005], rd[100005];
  cin >> n >> p;
  pd = (long double)p;
  long long l, r, ll, rr;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    ld[i] = (long double)l;
    rd[i] = (long double)r;
    a[i] = (r / p) - ((l - 1) / p);
  }
  a[n] = a[0];
  ld[n] = ld[0];
  rd[n] = rd[0];
  long double ans = 0, cur;
  for (int i = 0; i < n; i++) {
    cur = 0;
    cur += ((a[i] / (rd[i] - ld[i] + 1)) *
            ((rd[i + 1] - ld[i + 1] + 1 - a[i + 1]) /
             (rd[i + 1] - ld[i + 1] + 1)));
    cur += ((a[i + 1] / (rd[i + 1] - ld[i + 1] + 1)) *
            ((rd[i] - ld[i] + 1 - a[i]) / (rd[i] - ld[i] + 1)));
    cur += ((a[i] / (rd[i] - ld[i] + 1)) *
            (a[i + 1] / (rd[i + 1] - ld[i + 1] + 1)));
    ans += cur * 2000;
  }
  cout << fixed << setprecision(8) << ans << "\n";
  return 0;
}
