#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, count = 0;
  cin >> n;
  cin >> m;
  int* p = new int[m];
  int* q = new int[m];
  for (int i = 0; i < m; i++) {
    cin >> *(p + i);
    cin >> *(q + i);
  }
  for (int i = m - 1; i > 0; i--) {
    for (int j = 0; j < i; j++)
      if (*(q + j) < *(q + j + 1)) {
        swap(*(p + j), *(p + j + 1));
        swap(*(q + j), *(q + j + 1));
      }
  }
  int f = 0;
  while ((n > 0) && (f + 1 <= m)) {
    if (n <= *(p + f))
      count += n * (*(q + f));
    else
      count += *(p + f) * (*(q + f));
    n -= *(p + f);
    f++;
  }
  cout << count;
  return 0;
}
