#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const long double EPS = 1e-9;
const int N = 510;
const long long int INF = 1E8;
const long long int MOD = 1000000007;
long long int p;
long long int calc(pair<long long int, long long int> a) {
  long long int up = a.first % p;
  if (up != 0) {
    up = p - up;
    a.first += up;
  }
  long long int down = a.second % p;
  a.second -= down;
  if (a.second >= a.first) {
    return (a.second - a.first) / p + 1;
  }
  return 0;
}
double solve(pair<long long int, long long int> a,
             pair<long long int, long long int> b) {
  long long int ans = calc(a) * (b.second - b.first + 1) +
                      calc(b) * (a.second - a.first + 1) - calc(a) * calc(b);
  return ans * 1.0 / (b.second - b.first + 1) / (a.second - a.first + 1);
}
int main() {
  srand(13);
  cout << fixed << setprecision(10);
  long long int n;
  cin >> n;
  cin >> p;
  double ans = 0;
  vector<pair<long long int, long long int> > arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].first >> arr[i].second;
  }
  for (int i = 0; i < n; ++i) {
    ans += solve(arr[i], arr[(i + 1) % n]);
  }
  cout << ans * 2000;
  return 0;
}
