#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) {
    long long n, m, b, a, sum = 0, k = 0;
    cin >> n >> m;
    std::vector<pair<long long, long long>> v;
    for (int i = 0; i <= m - 1; i++) {
      cin >> a >> b;
      v.push_back({b, a});
    }
    sort(v.begin(), v.end());
    for (int i = m - 1; i >= 0; i--) {
      if (v[i].second > n - k) {
        sum += (v[i].first) * (n - k);
        break;
      } else {
        sum += (v[i].first) * (v[i].second);
        k += v[i].second;
      }
    }
    cout << sum;
  }
  cerr << "Time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
