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