#include <bits/stdc++.h>
using namespace std;
int i, n, p;
long long L[102400], M[102400];
double ans;
int main() {
  scanf("%d%d", &n, &p);
  for (i = 0; i < n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    L[i] = r - l + 1;
    M[i] = r / p - l / p;
    if (l % p == 0) M[i]++;
  }
  for (i = 0; i < n; i++) {
    int k = i + 1;
    if (k == n) k = 0;
    double total = L[i] * L[k];
    double win = M[i] * L[k] + (L[i] - M[i]) * M[k];
    ans += 2000 * win / total;
  }
  printf("%.9f", ans);
}
