#include <bits/stdc++.h>
using namespace std;
long long int inf = 1000005;
long long int a[1000005], sz[1000005];
int main() {
  long long int n, p, l, r;
  cin >> n >> p;
  double ans = 0.0;
  for (long long int i = 0; i < n; i++) {
    cin >> l >> r;
    sz[i] = (r - l) + 1;
    a[i] = r / p - (l - 1) / p;
  }
  a[n] = a[0];
  sz[n] = sz[0];
  for (long long int i = 0; i < n; i++)
    ans += (1.0 - ((sz[i] - a[i]) * (sz[i + 1] - a[i + 1]) * 1.0) /
                      (sz[i] * sz[i + 1] * 1.0));
  cout << fixed << setprecision(10);
  cout << ans * 2000;
  return 0;
}
