#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, a, s[11] = {0}, k = 0;
  int m, b, i;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    s[b] += a;
  }
  i = 10;
  while (n && i > 0) {
    if (n >= s[i]) {
      k += i * s[i];
      n -= s[i];
      i--;
    } else {
      k += i * n;
      n = 0;
    }
  }
  cout << k;
  return 0;
}
