#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> matchboxes[21];
bool CMP(const pair<long long, long long> &a,
         const pair<long long, long long> &b);
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> matchboxes[i].first >> matchboxes[i].second;
  }
  sort(matchboxes, matchboxes + m, CMP);
  int i = 0, max = 0, n2 = n;
  while (n2 != 0 and i < n) {
    if (n2 >= matchboxes[i].first) {
      max += matchboxes[i].first * matchboxes[i].second;
      n2 -= matchboxes[i].first;
    } else {
      max += n2 * matchboxes[i].second;
      n2 -= n2;
    }
    i++;
  }
  cout << max << endl;
  return 0;
}
bool CMP(const pair<long long, long long> &a,
         const pair<long long, long long> &b) {
  return a.second > b.second;
}
