#include <bits/stdc++.h>
using namespace std;
static const int mxn = 21;
long long n, res;
int m;
struct Node {
  long long a;
  int b;
  bool operator<(const Node& c) const { return b > c.b; }
} nodes[mxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> nodes[i].a >> nodes[i].b;
  }
  sort(nodes + 1, nodes + 1 + m);
  for (int i = 1; i <= m; ++i) {
    if (n >= nodes[i].a) {
      res += nodes[i].a * nodes[i].b;
      n -= nodes[i].a;
    } else {
      res += n * nodes[i].b;
      break;
    }
  }
  cout << res << '\n';
  return 0;
}
