#include <bits/stdc++.h>
using namespace std;
long long N, M, cnt;
pair<long long, long long> CC[21];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    CC[i].first = b, CC[i].second = a;
  }
  sort(CC, CC + M);
  for (int i = M - 1; i >= 0 && N; i--) {
    cnt += min(N, CC[i].second) * 1L * CC[i].first;
    N -= min(N, CC[i].second);
  }
  cout << cnt << endl;
  return 0;
}
