#include <bits/stdc++.h>
using namespace std;
const int mxn = 21;
long long res, n, b[mxn];
int m, a[mxn], idx[mxn];
bool cmp1(int x, int y) { return b[x] > b[y]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> a[i] >> b[i];
    idx[i] = i;
  }
  sort(idx + 1, idx + m + 1, cmp1);
  for (int i = 1; i <= m; ++i) {
    if (n >= a[idx[i]]) {
      res += a[idx[i]] * b[idx[i]];
      n -= a[idx[i]];
    } else {
      res += n * b[idx[i]];
      break;
    }
  }
  cout << res << '\n';
  return 0;
}
