#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x *= f;
}
int n, d, e, m, ans, w[20];
bool f[100000005];
int main() {
  n = read();
  d = read();
  e = read();
  w[1] = d;
  w[2] = 2 * d;
  w[3] = 5 * d;
  w[4] = 10 * d;
  w[5] = 20 * d;
  w[6] = 50 * d;
  w[7] = 100 * d;
  w[8] = 5 * e;
  w[9] = 10 * e;
  w[10] = 20 * e;
  w[11] = 50 * e;
  w[12] = 100 * e;
  w[13] = 200 * e;
  sort(w + 1, w + 14);
  m = unique(w + 1, w + 14) - w - 1;
  f[0] = true;
  for (int i = 1; i <= m; i++)
    for (int j = w[i]; j <= n; j++)
      if (f[j - w[i]]) f[j] = true;
  for (int i = n; i >= 0; i--)
    if (f[i]) {
      ans = i;
      break;
    }
  printf("%d", n - ans);
  return 0;
}
