#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int arr[m][2];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> arr[i][j];
    }
  }
  long long sum = 0;
  int z = n;
  while (n > -1) {
    int max = 0, index = 0;
    for (int i = 0; i < m; i++) {
      if (arr[i][1] > max) {
        max = arr[i][1];
        index = i;
      }
    }
    arr[index][1] = 0;
    int q = n - arr[index][0];
    if (q > 0) {
      sum = sum + (arr[index][0] * max);
    } else {
      sum = sum + (n * max);
    }
    n -= arr[index][0];
  }
  cout << sum;
}
