#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, p;
  long double sum = 0;
  pair<int, int> a[100007];
  scanf("%d%d", &n, &p);
  for (long long i = 0; i <= (long long)n - 1; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    a[i] = {r / p - (l - 1) / p, r - l + 1};
  }
  for (int i = 0; i < n; i++) {
    long long aa = a[i].second - a[i].first;
    long long bb = a[(i + 1) % n].second - a[(i + 1) % n].first;
    long double k =
        1 - ((aa * 1.0 / a[i].second) * (bb * 1.0 / a[(i + 1) % n].second));
    sum += k * 2000;
  }
  cout << fixed << setprecision(10) << sum;
}
