#include <bits/stdc++.h>
using namespace std;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  s << "[";
  for (int i = 0; i < ((int)(t.size())) - 1; i++) s << t[i] << ", ";
  s << t[((int)(t.size())) - 1] << "]";
  return s;
}
const int MOD = 1e9 + 7;
template <typename T>
inline T gcD(T a, T b) {
  if (a < b) swap(a, b);
  while (b) {
    a = a % b;
    b ^= a;
    a ^= b;
    b ^= a;
  };
  return a;
}
template <typename T>
inline T pow_mod(T a, T b) {
  T res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
int main() {
  int a, b, c;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  if (c == 0) {
    if (b == a)
      puts("YES");
    else
      puts("NO");
  } else if ((b - a) % c == 0) {
    if (c > 0 && b >= a)
      puts("YES");
    else if (c < 0 && b <= a)
      puts("YES");
    else
      puts("NO");
  } else
    puts("NO");
}
