#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N, P;
long double prob[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N >> P;
  for (int(i) = 0; (i) < (N); (i)++) {
    long long l, r;
    cin >> l >> r;
    prob[i] = (long double)((r / P) - ((l - 1) / P)) / (r - l + 1);
  }
  long double answer = 0;
  for (int(i) = 0; (i) < (N); (i)++)
    answer += (1 - (1 - prob[i]) * (1 - prob[(i + 1) % N]));
  answer *= 2000;
  cout << answer << '\n';
}
