#include <bits/stdc++.h>
int main() {
  long long int a, b, c;
  scanf("%lld", &a);
  scanf("%lld", &b);
  scanf("%lld", &c);
  if (a == b) {
    printf("YES");
  } else if (a == 0) {
    if (((b > 0 && c > 0) || (b < 0 && c < 0)) && (b % c == 0))
      printf("YES");
    else if (b == 0 && c == 0)
      printf("YES");
    else
      printf("NO");
  } else if (b == 0) {
    if (((a > 0 && c < 0) || (a < 0 && c > 0)) && (a % c == 0))
      printf("YES");
    else
      printf("NO");
  } else if (c == 0) {
    if (a == b)
      printf("YES");
    else
      printf("NO");
  } else if ((b - a) > 0) {
    if (c > 0 && ((b - a) % c == 0))
      printf("YES");
    else
      printf("NO");
  } else if ((b - a) < 0) {
    if (c < 0 && ((b - a) % c == 0))
      printf("YES");
    else
      printf("NO");
  }
  return 0;
}
