#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> l, pair<int, int> r) { return (l.first < r.first); }
priority_queue<int, vector<int>, greater<int> > pq;
long long int n, p, l[1000006], r[1000006];
double n1, n2, ans;
int main() {
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  for (int i = 0; i < n; i++) {
    n1 = (r[i] / p) - ((l[i] - 1) / p);
    n2 = (r[(i + 1) % n] / p) - ((l[(i + 1) % n] - 1) / p);
    n1 = n1 / (r[i] - l[i] + 1);
    n2 = n2 / (r[(i + 1) % n] - l[(i + 1) % n] + 1);
    ans += 1000 * (n1 + n2 - n1 * n2);
  }
  printf("%.8lf", ans * 2);
  return 0;
}
