#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
pair<long long, long long> v[25];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> v[i].second >> v[i].first;
  sort(v + 1, v + m + 1);
  long long k = m;
  while (k and n) {
    ans += min(n, v[k].second) * v[k].first;
    n -= min(n, v[k].second);
    k--;
  }
  cout << ans << endl;
  return 0;
}
