#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
pair<int, int> v[30];
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v[i] = pair<int, int>(a, b);
  }
  sort(v, v + m, cmp);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (n >= v[i].first) {
      ans += v[i].second * v[i].first;
      n -= v[i].first;
    } else {
      ans += v[i].second * n;
      n = 0;
    }
    if (!n) break;
  }
  cout << ans;
}
