#include <bits/stdc++.h>
using namespace std;
long long pcnts[100001];
long long ncnts[100001];
int main() {
  int n, p;
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    long double c = r / p;
    c -= (l - 1) / p;
    pcnts[i] = c;
    ncnts[i] = r - l + 1;
  }
  long double ans = 0;
  for (int i = 1; i < n; i++) {
    long double p1 = pcnts[i - 1];
    long double p2 = pcnts[i];
    long double n1 = ncnts[i - 1];
    long double n2 = ncnts[i];
    long double t = (p1 * p2) + p1 * (n2 - p2) + p2 * (n1 - p1);
    long double d = n1 * n2;
    t /= d;
    t *= 2000;
    ans += t;
  }
  long double p1 = pcnts[0];
  long double p2 = pcnts[n - 1];
  long double n1 = ncnts[0];
  long double n2 = ncnts[n - 1];
  long double t = (p1 * p2) + p1 * (n2 - p2) + p2 * (n1 - p1);
  long double d = n1 * n2;
  t /= d;
  t *= 2000;
  ans += t;
  cout << setprecision(10) << ans << endl;
  return 0;
}
