#include <bits/stdc++.h>
using namespace std;
unsigned long long GCD(unsigned long long x, unsigned long long y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}
unsigned long long LCM(unsigned long long a, unsigned long long b) {
  return (a * b / (GCD(a, b)));
}
bool lol(tuple<long long, long long, long long>& k,
         tuple<long long, long long, long long>& l) {
  return (get<1>(k) > get<1>(l));
}
int main() {
  long long a, b, c, d, e, t, i, j, k, sum = 0, ans = 0, x, y, z, m, n;
  string S, T, U;
  cin >> a >> b;
  vector<tuple<long long, long long, long long>> Z;
  for (i = 0; i < b; i++) {
    cin >> c >> d;
    e = c * d;
    Z.push_back(make_tuple(c, d, e));
  }
  sort(Z.begin(), Z.end(), lol);
  if (a <= get<0>(Z[0])) {
    sum = a * get<1>(Z[0]);
    cout << sum << endl;
    return 0;
  }
  sum = get<0>(Z[0]) * get<1>(Z[0]);
  e = a;
  j = a - get<0>(Z[0]);
  for (i = 1; i < b; i++) {
    if (get<0>(Z[i]) > j) {
      sum += j * get<1>(Z[i]);
      break;
    } else {
      sum += get<0>(Z[i]) * get<1>(Z[i]);
      j -= get<0>(Z[i]);
    }
    if (j <= 0) break;
  }
  cout << sum << endl;
  return 0;
}
