#include <bits/stdc++.h>
using namespace std;
int M, N;
int freq[11] = {0};
int ai, bi, ans = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> ai >> bi;
    freq[bi] += ai;
  }
  for (int i = 10; (i >= 0) && N; --i) {
    int k = (freq[i] > N) ? N : freq[i];
    ans += k * i;
    N -= k;
  }
  cout << ans << '\n';
  return 0;
}
