#include <bits/stdc++.h>
using namespace std;
int main() {
  int bagcapacity, m, arr[20][20], count = 0, countMbox = 0, countm = 0;
  cin >> bagcapacity >> m;
  for (int i = 0; i < m; i++) {
    cin >> arr[i][0] >> arr[i][1];
    countMbox += arr[i][0];
    countm += arr[i][0] * arr[i][1];
  }
  if (countMbox <= bagcapacity) {
    cout << countm;
    return 0;
  }
  while (bagcapacity) {
    int x = 0;
    for (int i = 0; i < m; i++) {
      if (arr[x][1] < arr[i][1]) x = i;
    }
    if (bagcapacity <= arr[x][0]) {
      count += bagcapacity * arr[x][1];
      cout << count;
      return 0;
    } else {
      count += arr[x][0] * arr[x][1];
      bagcapacity = bagcapacity - arr[x][0];
      arr[x][1] = 0;
    }
  }
  return 0;
}
