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