#include <bits/stdc++.h>
using namespace std;
int mx(int arr[], int siz) {
  int mx = 0;
  for (int i = 0; i < siz; i++)
    if (arr[i] > arr[mx]) mx = i;
  return mx;
}
int main() {
  int n, m, idx = 0, ans = 0;
  cin >> n >> m;
  int arr1[m], arr2[m];
  for (int i = 0; i < m; i++) cin >> arr1[i] >> arr2[i];
  while (n > 0) {
    idx = mx(arr2, m);
    if (arr1[idx] >= n) {
      ans += arr2[idx] * n;
      n = 0;
    } else {
      ans += arr1[idx] * arr2[idx];
      n -= arr1[idx];
      arr2[idx] = 0;
    }
  }
  cout << ans;
  return 0;
}
