#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }
  if (c == 0) {
    if (b == a)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  if (c == 1) {
    if (b >= a)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  if (c == -1) {
    if (b <= a)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  if (c > 0 && b < a) {
    cout << "NO" << endl;
    return 0;
  }
  if (c < 0 && b > a) {
    cout << "NO" << endl;
    return 0;
  }
  int check1 = 0, check2 = 0;
  int term = a;
  while (b < term) {
    term = term + c;
    if (term == b) {
      check1 = 1;
      break;
    }
  }
  term = a;
  while (b > term) {
    term = term + c;
    if (term == b) {
      check2 = 1;
      break;
    }
  }
  if (check1 == 1 || check2 == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
