#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b, m, n, v;
  cin >> b >> m >> n >> v;
  long long h, c, s, ss = 0, bb;
  h = b;
  if (m != 1) {
    while (h != 1) {
      if (h >= m) {
        if (h % m == 0) {
          c = h / m;
          s = h - c;
          s = s * n;
          if (s <= v) {
            ss = ss + s;
            h = c;
          }
          if (s > v) {
            ss = ss + v;
            h = c;
          }
        } else {
          bb = h % m;
          h = h - bb;
          ss = ss + (bb * n);
        }
      } else {
        ss = ss + ((h - 1) * n);
        h = 1;
      }
    }
  } else {
    ss = ss + ((h - 1) * n);
  }
  cout << ss;
  return 0;
}
