#include <bits/stdc++.h>
using namespace std;
float arr[100005], nahi[100005];
int main() {
  int n, p, i, temp, l, r;
  cin >> n >> p;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &l, &r);
    if ((l % p == 0) && (r % p == 0)) {
      temp = (r / p) - (l / p) + 1;
    } else if ((l % p != 0) && (r % p == 0)) {
      temp = (r / p) - (l / p);
    } else if ((l % p == 0) && (r % p != 0)) {
      temp = (r / p) - (l / p) + 1;
    } else {
      temp = (r / p) - (l / p);
    }
    int total = (r - l + 1);
    float prob = ((float)temp) / total;
    arr[i] = prob;
  }
  for (i = 0; i < n; i++) {
    nahi[i] = (1 - (1 - arr[i]) * (1 - arr[(i + 1) % n]));
  }
  double ans = 0;
  for (i = 0; i < n; i++) {
    ans += nahi[i] * 2000;
  }
  printf("%.8lf\n", ans);
  return 0;
}
