#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> arr(m, {0, 0});
  for (int i = 0; i < m; i++) {
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr.begin(), arr.end(), comp);
  int k = 0;
  int t = 0;
  int i = 0;
  while (k != n && i < m) {
    int p = min(arr[i].first, n - k);
    t += p * arr[i].second;
    k += p;
    i++;
  }
  cout << t << "\n";
  return 0;
}
