#include <bits/stdc++.h>
using namespace std;
long long int r[1000002], c[1000002];
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, m, s;
  cin >> n >> m >> s;
  long long int i, max1 = -1, max2 = -1, cnt = 0, cnt2 = 0;
  for (i = 1; i <= n; i++) {
    r[i % s]++;
  }
  for (i = 1; i <= m; i++) {
    c[i % s]++;
  }
  for (i = 0; i < s; i++) {
    if (r[i] > max1) {
      max1 = r[i];
      cnt = 1;
    } else if (r[i] == max1) {
      cnt++;
    }
    if (max2 < c[i]) {
      max2 = c[i];
      cnt2 = 1;
    } else if (c[i] == max2) {
      cnt2++;
    }
  }
  cout << cnt * max1 * max2 * cnt2 << endl;
  return 0;
}
