#include <bits/stdc++.h>
using namespace std;
long long MAX = LLONG_MAX;
long long MOD = 1e9 + 7;
long long Mod = 1e9 + 7;
double EPS = 0.0001;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0};
int main() {
  int n, m, a, b, ans, nds;
  scanf("%d", &n);
  scanf("%d", &m);
  map<int, int> matches;
  map<int, int>::iterator it;
  nds = 0;
  for (long long i = 0; i < m; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    it = matches.find(b);
    if (it != matches.end())
      it->second += a;
    else
      matches.insert(make_pair(b, a)), nds++;
  }
  it = matches.end();
  it--;
  ans = 0;
  for (long long i = 0; i < nds; i++) {
    if (n <= 0) break;
    int mins = min(it->second, n);
    n -= mins;
    ans += it->first * mins;
    it--;
  }
  cout << ans;
  return 0;
}
