#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a, b, sum = 0, arr[25] = {0};
  cin >> n >> x;
  for (int i = 0; i < x; i++) {
    cin >> a >> b;
    arr[b] += a;
  }
  for (int i = 10; i >= 0; i--) {
    int s = min(n, arr[i]);
    sum += i * s;
    n -= s;
  }
  cout << sum << endl;
  return 0;
}
