#include <bits/stdc++.h>
using namespace std;
int cnt[20];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    cnt[b] += a;
  }
  int ans = 0;
  for (int i = 10; i >= 1; i--) {
    if (cnt[i] <= n)
      ans += cnt[i] * i, n -= cnt[i];
    else {
      ans += n * i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
