#include <bits/stdc++.h>
using namespace std;
int main() {
  long long add = 100000000005, a, b, c;
  cin >> a >> b >> c;
  a += add;
  b += add;
  if (b == a) {
    printf("YES\n");
    return 0;
  }
  if (c == 0) {
    printf("NO\n");
    return 0;
  }
  if (c > 0 && b < a) {
    printf("NO\n");
    return 0;
  }
  if (c < 0 && b > a) {
    printf("NO\n");
    return 0;
  }
  c = abs(c);
  if (b % c == a % c) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
