#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  if (c != 0) {
    if (c > 0) {
      if (b > a) {
        long long int n = (b - a) / c;
        if (c * n == b - a)
          cout << "YES";
        else
          cout << "NO";
      } else if (b < a) {
        cout << "NO";
      } else if (b == a) {
        cout << "YES";
      }
    } else {
      if (a > b) {
        long long int n = (b - a) / c;
        if (c * n == b - a)
          cout << "YES";
        else
          cout << "NO";
      } else if (b > a) {
        cout << "NO";
      } else if (a == b) {
        cout << "YES";
      }
    }
  } else {
    if (b == a)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
