#include <bits/stdc++.h>
using namespace std;
bool prime[100050 + 1];
void sieve1() {
  for (int i = 0; i <= 100050; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (long long int i = 4; i <= 100050; i += 2) prime[i] = 0;
  for (int p = 3; p * p <= 100050; p += 2) {
    if (prime[p] == 1)
      for (int i = p * 2; i <= 100050; i += p) {
        prime[i] = 0;
      }
  }
}
bool isvowel(char v) { return (0x208222 >> (v & 0x1f)) & 1; }
long long int mceil(long long int a, long long int b) {
  if (a % b == 0)
    return (a / b);
  else
    return (a / b + 1);
}
long long int mfloor(long long int a, long long int b) { return (a / b); }
long long modmul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
long long modadd(long long a, long long b) {
  return ((a % 1000000007) + (b % 1000000007) + 1000000007) % 1000000007;
}
long long modsub(long long a, long long b) {
  return ((a % 1000000007) - (b % 1000000007) + 1000000007) % 1000000007;
}
long long int fastexpo(long long int a, long long int b) {
  a = a % 1000000007;
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1ll * a) % 1000000007;
    a = (a * 1ll * a) % 1000000007;
    b = b / 2;
  }
  return ans;
}
void prime_factorise(long long int n, map<long long int, long long int> &mp) {
  while (n % 2 == 0) {
    mp[2]++;
    n /= 2;
  }
  for (long long int i = 3; i * i <= n; i += 2) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) mp[n]++;
}
long long int cntbits(long long int n) {
  long long int cnt = 0;
  while (n) {
    cnt++;
    n /= 2;
  }
  return cnt;
}
void chandan1() {
  int y = 1;
  return;
}
void chandan2() {
  for (long long int i = 0; i < 10; i++) {
    long long int x = 1;
  }
  return (chandan1());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  chandan2();
  while (t--) {
    long long int n, m, a, b;
    cin >> n >> m >> a >> b;
    long long int ans1 = n * a;
    long long int ans2 = ((n / m) * b + (n % m) * a);
    long long int ans3 = (n / m + 1) * b;
    printf("%lli\n", min({ans1, ans2, ans3}));
    ;
  }
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?

Input

The single line contains four space-separated integers n, m, a, b (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket. 

Output

Print a single integer — the minimum sum in rubles that Ann will need to spend.

Examples

Input

6 2 1 2


Output

6


Input

5 2 2 3


Output

8

Note

In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool prime[100050 + 1];
void sieve1() {
  for (int i = 0; i <= 100050; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (long long int i = 4; i <= 100050; i += 2) prime[i] = 0;
  for (int p = 3; p * p <= 100050; p += 2) {
    if (prime[p] == 1)
      for (int i = p * 2; i <= 100050; i += p) {
        prime[i] = 0;
      }
  }
}
bool isvowel(char v) { return (0x208222 >> (v & 0x1f)) & 1; }
long long int mceil(long long int a, long long int b) {
  if (a % b == 0)
    return (a / b);
  else
    return (a / b + 1);
}
long long int mfloor(long long int a, long long int b) { return (a / b); }
long long modmul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
long long modadd(long long a, long long b) {
  return ((a % 1000000007) + (b % 1000000007) + 1000000007) % 1000000007;
}
long long modsub(long long a, long long b) {
  return ((a % 1000000007) - (b % 1000000007) + 1000000007) % 1000000007;
}
long long int fastexpo(long long int a, long long int b) {
  a = a % 1000000007;
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1ll * a) % 1000000007;
    a = (a * 1ll * a) % 1000000007;
    b = b / 2;
  }
  return ans;
}
void prime_factorise(long long int n, map<long long int, long long int> &mp) {
  while (n % 2 == 0) {
    mp[2]++;
    n /= 2;
  }
  for (long long int i = 3; i * i <= n; i += 2) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) mp[n]++;
}
long long int cntbits(long long int n) {
  long long int cnt = 0;
  while (n) {
    cnt++;
    n /= 2;
  }
  return cnt;
}
void chandan1() {
  int y = 1;
  return;
}
void chandan2() {
  for (long long int i = 0; i < 10; i++) {
    long long int x = 1;
  }
  return (chandan1());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  chandan2();
  while (t--) {
    long long int n, m, a, b;
    cin >> n >> m >> a >> b;
    long long int ans1 = n * a;
    long long int ans2 = ((n / m) * b + (n % m) * a);
    long long int ans3 = (n / m + 1) * b;
    printf("%lli\n", min({ans1, ans2, ans3}));
    ;
  }
  return 0;
}

```