#include <bits/stdc++.h>
using namespace std;
bool compare(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
int main() {
  int n, m, a, b;
  cin >> n >> m;
  pair<int, int> p[m];
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p, p + m, compare);
  int i = 0, ans = 0;
  while (n > 0 && i < m) {
    a = p[i].first;
    b = p[i].second;
    if (n - a >= 0) {
      ans += (a * b);
      n = n - a;
    } else {
      ans += (n * b);
      n = n - a;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}
