#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<pair<int, int> > v1;
  int n, m, a, b, match = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v1.push_back(make_pair(b, a));
  }
  sort(v1.rbegin(), v1.rend());
  int j = 0;
  while (n > 0 && j != m) {
    if (n >= v1[j].second) {
      match += v1[j].first * v1[j].second;
      n -= v1[j].second;
    } else {
      match += v1[j].first * n;
      n = 0;
    }
    j++;
  }
  cout << match;
  return 0;
}
