#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, ans(0), x, y, i;
  cin >> n >> m;
  vector<pair<long long, long long> > v;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    v.push_back({y, x});
  }
  sort(v.begin(), v.end());
  i = m - 1;
  while (n > 0 and i > -1) {
    ans += (min(v[i].second, n) * v[i].first);
    n -= min(v[i].second, n);
    i--;
  }
  cout << ans;
  return 0;
}
