#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897932384626433832795;
const int inf = 1e9;
const long long inf2 = 1e18;
const int mod = 1e9 + 7;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {
  int n;
  cin >> n;
  long long p;
  cin >> p;
  vector<pair<int, int>> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].first >> arr[i].second;
  }
  long double ans = 0;
  long double num, den;
  long double val = 2000;
  for (int i = 0; i < n; i++) {
    int j = (i + 1) % n;
    num = arr[i].second + 1 - arr[i].first -
          ((arr[i].second / p) - (arr[i].first - 1) / p);
    den = arr[i].second - arr[i].first + 1;
    num *= arr[j].second + 1 - arr[j].first -
           ((arr[j].second / p) - (arr[j].first - 1) / p);
    den *= arr[j].second - arr[j].first + 1;
    ans += (1.0 - (num / den)) * val;
  }
  cout << fixed << setprecision(8) << ans << endl;
  return;
}
int main() {
  boost();
  int tc = 1;
  while (tc--) solve();
  return 0;
}
