#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, matches = 0;
  cin >> n >> m;
  vector<pair<int, int> > v(m);
  pair<int, int> tmp;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end(),
       [](const pair<int, int> &a1, const pair<int, int> &b2) {
         return (b2.second < a1.second);
       });
  for (int i = 0; i < m; ++i) {
    tmp = v.at(i);
    if (n > tmp.first) {
      matches += tmp.first * tmp.second;
      n -= tmp.first;
    } else {
      matches += n * tmp.second;
      break;
    }
  }
  cout << matches;
}
