#include <bits/stdc++.h>
using namespace std;
long long gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int main(void) {
  int a = ({
    int a;
    scanf("%d", &a);
    a;
  }),
      b = ({
        int a;
        scanf("%d", &a);
        a;
      }),
      c = ({
        int a;
        scanf("%d", &a);
        a;
      });
  if (!c) {
    if (a == b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  double x1 = (b - a) * 1.0 / c * 1.0;
  double x2 = (a - b) * 1.0 / c * 1.0;
  if ((floor(x1) == ceil(x1) || floor(x2) == ceil(x2)) &&
      ((b >= a && c > 0) || (b <= a && c < 0))) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
