#include <bits/stdc++.h>
using namespace std;
int a[10005];
int b[10005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      if (b[i] > b[j]) {
        swap(a[i], a[j]);
        swap(b[i], b[j]);
      }
    }
  }
  for (int i = 1; true; i++) {
    if (a[i] >= n) {
      ans += n * b[i];
      break;
    } else {
      ans += b[i] * a[i];
      n -= a[i];
    }
  }
  printf("%d", ans);
  return 0;
}
