#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, p;
  cin >> n >> p;
  long long i, l[n + 1], r[n + 1];
  long long div[n + 1], no[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    no[i] = r[i] - l[i] + 1;
    div[i] = no[i] -
             max(0, int(floor(double(r[i]) / p) - ceil(double(l[i]) / p) + 1));
  }
  double ans = 0;
  for (i = 1; i <= n; i++) {
    if (i == 1) {
      long long val1 = (no[i] * no[i + 1]) - (div[i] * div[i + 1]);
      ans += double(val1) / (no[i] * no[i + 1]);
      long long val2 = (no[i] * no[n]) - (div[i] * div[n]);
      ans += double(val2) / (no[i] * no[n]);
    } else if (i == n) {
      long long val1 = (no[i] * no[1]) - (div[i] * div[1]);
      ans += double(val1) / (no[i] * no[1]);
      long long val2 = (no[i] * no[i - 1]) - (div[i] * div[i - 1]);
      ans += double(val2) / (no[i] * no[i - 1]);
    } else {
      long long val1 = (no[i] * no[i + 1]) - (div[i] * div[i + 1]);
      ans += double(val1) / (no[i] * no[i + 1]);
      long long val2 = (no[i] * no[i - 1]) - (div[i] * div[i - 1]);
      ans += double(val2) / (no[i] * no[i - 1]);
    }
  }
  cout.precision(25);
  cout << std::fixed << ans * 1000;
}
