#include <bits/stdc++.h>
using namespace std;
int a[1000009], b[1000009];
int main() {
  long long int i, j, k, l, m, n, flag, count, sum, ans, t, A, B, C, D, x, y, z,
      diff, count2, count3;
  cin >> i >> j >> k;
  if (i == j)
    ans = 1;
  else if (k == 0)
    ans = 0;
  else if (i > j && k > 0)
    ans = 0;
  else if (j > i && k < 0)
    ans = 0;
  else {
    count = j - i;
    if (count % k)
      ans = 0;
    else
      ans = 1;
  }
  if (ans == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
