#include <bits/stdc++.h>
using namespace std;
struct T {
  int x, y;
} a[105];
int n, m;
bool cmp(T x, T y) { return x.y > y.y; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &a[i].x, &a[i].y);
  sort(a + 1, a + m + 1, cmp);
  int ans = 0;
  for (int i = 1; i <= m && n > 0; ++i)
    ans += a[i].y * min(n, a[i].x), n -= min(n, a[i].x);
  printf("%d\n", ans);
  return 0;
}
