#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d, e;
  cin >> n >> d >> e;
  int rubles[] = {1, 2, 5, 10, 20, 50, 100, 5, 10, 20, 50, 100, 200};
  for (int i = 0; i < 7; i++) rubles[i] *= d;
  for (int i = 7; i < 13; i++) rubles[i] *= e;
  vector<int> dp(n + 1, 0);
  for (int i = 0; i < 13; i++) {
    for (int j = rubles[i]; j <= n; j++)
      dp[j] = max(dp[j], dp[j - rubles[i]] + rubles[i]);
  }
  cout << n - dp[n] << '\n';
  return 0;
}
