#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  short m;
  cin >> n >> m;
  vector<pair<short, int>> nrs;
  for (short i = 0; i < m; ++i) {
    pair<short, int> nr;
    cin >> nr.second >> nr.first;
    nrs.emplace_back(nr);
  }
  sort(begin(nrs), end(nrs), greater<pair<short, int>>());
  int res = 0;
  for (short i = 0; i < m; ++i) {
    if (nrs[i].second > n) {
      cout << res + n * nrs[i].first;
      return 0;
    } else {
      res += nrs[i].second * nrs[i].first;
      n -= nrs[i].second;
    }
  }
  cout << res;
}
