#include <bits/stdc++.h>
const int N = 1e5 + 10;
const long long mod = 100000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
int n, k;
int wl[N], wh[N];
int cmp(const void* a, const void* b) { return *(int*)b - *(int*)a; }
int main() {
  int i, day = 0, t, a = 0, b = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> t;
    if (t <= k) {
      wl[a++] = t;
    } else
      wh[b++] = t;
  }
  int j = 0;
  for (i = 0; i < b; i++) {
    if (wh[i] >= 2 * k) {
      while (wh[i] >= 2 * k) {
        wh[i] -= 2 * k;
        day++;
      }
      if (wh[i] <= k && wh[i]) {
        wl[a++] = wh[i];
        wh[i] = 0;
      } else if (wh[i] > k) {
        wl[a++] = wh[i] - k;
        wh[i] = 0;
        if (j < a) wl[j++] = 0;
        day++;
      }
    } else if (wh[i] > k) {
      wl[a++] = wh[i] - k;
      if (j < a) wl[j++] = 0;
      day++;
    }
  }
  for (i = 0; i < a; i++) {
    if (wl[i] != 0) break;
  }
  if (i < a) {
    if ((a - i) % 2 == 0)
      day += (a - i) / 2;
    else
      day += (a - i) / 2 + 1;
  }
  printf("%d\n", day);
  return 0;
}
