#include <bits/stdc++.h>
using namespace std;
void b_sort(int box[], int match[], int start, int stop);
int partition_(int box[], int match[], int start, int stop);
int main() {
  int n, m;
  cin >> n >> m;
  int box[m];
  int match[m];
  int i;
  for (i = 0; i < m; i++) {
    cin >> box[i];
    cin >> match[i];
  }
  b_sort(box, match, 0, m - 1);
  int rem = n;
  long long int total = 0;
  for (i = m - 1; i >= 0; i--) {
    if (rem <= 0)
      break;
    else {
      if (rem >= box[i]) {
        rem = rem - box[i];
        total = total + box[i] * match[i];
      } else {
        total = total + rem * match[i];
        rem = 0;
      }
    }
  }
  cout << total;
}
void b_sort(int box[], int match[], int start, int stop) {
  if (start >= stop) return;
  int p = partition_(box, match, start, stop);
  b_sort(box, match, start, p - 1);
  b_sort(box, match, p + 1, stop);
}
int partition_(int box[], int match[], int start, int stop) {
  int i, j;
  int x = match[stop];
  i = start - 1;
  int temp;
  for (j = start; j < stop; j++) {
    if (match[j] < x) {
      i++;
      temp = match[i];
      match[i] = match[j];
      match[j] = temp;
      temp = box[i];
      box[i] = box[j];
      box[j] = temp;
    }
  }
  i++;
  temp = match[i];
  match[i] = match[stop];
  match[stop] = temp;
  temp = box[i];
  box[i] = box[stop];
  box[stop] = temp;
  return i;
}
