#include <bits/stdc++.h>
using namespace std;
long double pi = 3.141592653589793238;
set<long long>::iterator it;
multiset<long long>::iterator itr;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long m, a, b;
    cin >> m >> a >> b;
    long long r = n % m;
    cout << min(b * (r), a * (m - r)) << endl;
  }
}
