#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    int k = r / p - (l - 1) / p;
    a[i] = 1.0 * k / (r - l + 1);
  }
  double ans = 4.0 * a[0] - 2.0 * a[0] * a[n - 1];
  for (int i = 1; i < n; i++) ans += 4.0 * a[i] - 2.0 * a[i] * a[i - 1];
  cout.precision(7);
  cout << ans * 1000 << endl;
}
