#include <bits/stdc++.h>
int dx4[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int dx8[][2] = {{0, 1}, {0, -1}, {1, 1},  {1, -1},
                {1, 0}, {-1, 0}, {-1, 1}, {-1, -1}};
using namespace std;
int main(int argc, char *argv[]) {
  long long n;
  cin >> n;
  long long p;
  cin >> p;
  vector<pair<int, int> > v(n);
  double P = p;
  vector<long long> primes(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    int p1 = ceil(v[i].first / P) * p;
    int p2 = floor(v[i].second / P) * p;
    primes[i] = (p2 - p1) / p + 1;
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    long long r1 = v[i].second - v[i].first + 1;
    ;
    long long r2 = v[(i + 1) % n].second - v[(i + 1) % n].first + 1;
    ;
    double pro = (r1 - primes[i]) * primes[(i + 1) % n] +
                 (r2 - primes[(i + 1) % n]) * primes[i] +
                 primes[i] * primes[(i + 1) % n];
    double tot = r1 * r2;
    ans = ans + (pro / tot) * 2000;
  }
  printf("%lf\n", ans);
  return 0;
}
