#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  pair<int, int> a[m];
  for (int i = 0; i < m; i++) {
    int a1, b;
    cin >> a1 >> b;
    a[i] = make_pair(a1, b);
  }
  sort(a, a + m, cmp);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (n <= a[i].first) {
      ans += n * a[i].second;
      break;
    } else
      ans += a[i].first * a[i].second, n -= a[i].first;
  }
  cout << ans;
  return 0;
}
