#include <bits/stdc++.h>
using namespace std;
long long l[100001];
long long r[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, p;
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  l[n] = l[0];
  r[n] = r[0];
  double expectedValue = 0;
  for (int i = 0; i < n; i++) {
    long long good1 = r[i] / p - (l[i] - 1) / p;
    long long good2 = r[i + 1] / p - (l[i + 1] - 1) / p;
    long long range1 = r[i] - l[i] + 1;
    long long range2 = r[i + 1] - l[i + 1] + 1;
    double total = range1 * range2;
    double probability =
        (good1 * range2 + good2 * range1 - good1 * good2) / total;
    expectedValue += probability;
  }
  expectedValue *= 2000.0;
  cout.precision(20);
  cout << expectedValue;
}
