#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int nxt();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(m);
  for (auto& ai : a) {
    cin >> ai.second >> ai.first;
  }
  sort((a).begin(), (a).end(), greater<pair<int, int>>());
  int ans = 0;
  int mb = 0;
  int j = 0;
  while (j < m) {
    int omb = mb;
    mb = min(mb + a[j].second, n);
    ans += (mb - omb) * a[j].first;
    j++;
  }
  cout << ans << endl;
  return 0;
}
int nxt() {
  int x;
  cin >> x;
  return x;
}
