#include <bits/stdc++.h>
using namespace std;
int n, m, a[100], b[100];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> a[i] >> b[i];
  for (int i = 1; i < m; i++)
    for (int j = i + 1; j <= m; j++)
      if (b[i] < b[j]) {
        swap(b[i], b[j]);
        swap(a[i], a[j]);
      }
  int ans = 0, i = 1;
  while (n > 0) {
    int k = min(a[i], n);
    ans += b[i] * k;
    n -= k;
    i++;
  }
  cout << ans << endl;
  return 0;
}
