#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-Wconversion"
using namespace std;
int main() {
  int m;
  long long n, mt = 0;
  pair<long long, long long> arr[25];
  cin >> n >> m;
  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 (arr[i].second <= n) {
      mt += (arr[i].first * arr[i].second);
      n -= arr[i].second;
    } else {
      mt += n * arr[i].first;
      break;
    }
  }
  cout << mt;
}
