#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a[21], b[21], countmatch = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i] > b[j]) {
        swap(b[i], b[j]);
        swap(a[i], a[j]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    if (a[i] <= n) {
      countmatch += a[i] * b[i];
      n -= a[i];
    } else {
      countmatch += n * b[i];
      break;
    }
  }
  cout << countmatch;
}
