#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second > b.second) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > vect(m);
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    vect[i] = {x, y};
  }
  sort(vect.begin(), vect.end(), cmp);
  long long count = 0;
  for (long long i = 0; i < m; i++) {
    if (n >= vect[i].first) {
      count += vect[i].first * vect[i].second;
      n -= vect[i].first;
    } else {
      count += n * vect[i].second;
      break;
    }
  }
  cout << count << "\n";
  return 0;
}
