#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  bool x = false;
  cin >> a >> b >> c;
  if (c > 0) {
    while (a <= b) {
      if (a == b) {
        cout << "YES";
        x = true;
        break;
      }
      a += c;
    }
    if (!x) {
      cout << "NO";
    }
  } else if (c == 0) {
    if (a == b) {
      cout << "YES";
    } else {
      cout << "NO";
    }
  } else {
    while (a >= b) {
      if (a == b) {
        cout << "YES";
        x = true;
        break;
      }
      a += c;
    }
    if (!x) {
      cout << "NO";
    }
  }
}
