#include <bits/stdc++.h>
using namespace std;
long long int mx(long long int a[], long long int n) {
  return *(max_element(a, a + n));
}
long long int mi(long long int a[], long long int n) {
  return *(min_element(a, a + n));
}
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000009;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000009;
    y = y >> 1;
    x = (x * x) % 1000000009;
  }
  return res % 1000000009;
}
long double power1(long double x, long long int y) {
  long double res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }
long long int upperIndex(long long int arr[], long long int n,
                         long long int y) {
  long long int l = 0, h = n;
  while (l <= h) {
    long long int mid = (l + h) / 2;
    if (arr[mid] < y)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return h;
}
void pa(long long int a[], long long int n) {
  for (long long int i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void ga(long long int a[], long long int n) {
  for (long long int i = 0; i < n; i++) cin >> a[i];
}
template <typename T>
void print_queue(T& q) {
  while (!q.empty()) {
    std::cout << q.top() << " ";
    q.pop();
  }
  std::cout << '\n';
}
void sor(long long int a[], long long int b[], long long int n) {
  vector<pair<long long int, long long int>> v;
  for (long long int i = 0; i < n; i++) {
    v.push_back(make_pair(a[i], b[i]));
  }
  sort(v.begin(), v.end());
  for (long long int i = 0; i < n; i++) {
    a[i] = v[i].first;
    b[i] = v[i].second;
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long int n, p;
  cin >> n >> p;
  long long int l[n], r[n];
  long long int a[n], b[n];
  long double ans = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    a[i] = r[i] / p;
    a[i] -= (l[i] - 1) / p;
    b[i] = r[i] - l[i] + 1;
  }
  for (long long int i = 0; i < n - 1; i++) {
    long long int x1 = (a[i] * b[i + 1]);
    x1 += a[i + 1] * (b[i] - a[i]);
    long long int x2 = (b[i] * b[i + 1]);
    ans += (long double)x1 / x2;
  }
  long long int x1 = (a[n - 1] * b[0]);
  x1 += a[0] * (b[n - 1] - a[n - 1]);
  long long int x2 = (b[n - 1] * b[0]);
  ans += (long double)x1 / x2;
  ans = (long double)ans * 2000;
  cout << fixed << setprecision(6) << ans;
  return 0;
}
