#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
int main() {
  vector<pair<int, int> > conInfo;
  int a, b, sum, i, n, m;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    conInfo.push_back(make_pair(a, b));
  }
  sort(conInfo.begin(), conInfo.end(), sortbysec);
  i = 0;
  sum = 0;
  while (n > 0) {
    if (n > conInfo[i].first) {
      n -= conInfo[i].first;
      sum += conInfo[i].first * conInfo[i].second;
      i++;
    } else {
      sum += n * conInfo[i].second;
      n = 0;
    }
    if (i > m - 1) {
      break;
    }
  }
  cout << sum << endl;
  conInfo.clear();
}
