#include <bits/stdc++.h>
using namespace std;
double a[100005];
int p;
int find(int x, int y) {
  int l, r;
  if (x % p == 0)
    l = x / p;
  else
    l = x / p + 1;
  if (y % p == 0)
    r = y / p;
  else
    r = y / p;
  return max(r - l + 1, 0);
}
int main() {
  int i;
  int n;
  scanf("%d %d", &n, &p);
  for (i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    a[i] = find(x, y) * 1.0 / (y - x + 1);
  }
  a[0] = a[n], a[n + 1] = a[1];
  double ans = 0;
  for (i = 1; i <= n; i++) {
    ans += (a[i]) + ((1 - a[i]) * a[i - 1] + (1 - a[i]) * a[i + 1]) / 2;
  }
  printf("%.8lf", ans * 2000);
}
