#include <bits/stdc++.h>
using namespace std;
int n, m, s;
long long num1[1050000], num2[1050000], apptimes[1050000];
long long maxi1, maxi2;
int main() {
  cin >> n >> m >> s;
  maxi1 = 0;
  for (int i = 1; i <= m; i++) {
    num1[i] = 1;
    long long t1 = (i - 1) / s;
    num1[i] += t1;
    t1 = (m - i) / s;
    num1[i] += t1;
    maxi1 = max(maxi1, num1[i]);
  }
  maxi2 = 0;
  for (int i = 1; i <= n; i++) {
    num2[i] = 1;
    long long t1 = (i - 1) / s;
    num2[i] += t1;
    t1 = (n - i) / s;
    num2[i] += t1;
    apptimes[num2[i]] += 1;
    maxi2 = max(maxi2, num2[i]);
  }
  long long maxi = maxi1 * maxi2;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    if (maxi % num1[i] == 0) {
      long long t = maxi / num1[i];
      ans += apptimes[t];
    }
  }
  cout << ans << endl;
}
