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