#include <bits/stdc++.h>
using namespace std;
int main() {
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long c[11]{};
  for (int i = 0; i != m; ++i) {
    long long a, b;
    cin >> a >> b;
    c[b] += a;
  }
  long long amt = 0;
  for (long long i = 10; i >= 1; --i) {
    amt += min(c[i], n) * i;
    n -= c[i];
    if (n <= 0) break;
  }
  cout << amt;
  return 0;
}
