#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, counter = 0;
  cin >> n >> m;
  pair<int, int> arr[20];
  for (int i = 0; i < m; i++) {
    cin >> arr[i].second >> arr[i].first;
  }
  sort(arr, arr + m);
  for (int i = m - 1; i >= 0; i--) {
    if (n - arr[i].second <= 0) {
      counter += n * arr[i].first;
      break;
    } else if (n - arr[i].second > 0) {
      counter += arr[i].second * arr[i].first;
      n = n - arr[i].second;
    }
  }
  cout << counter;
  return 0;
}
