#include <bits/stdc++.h>
long long int power(long long int x, long long int n) {
  long long int result = 1;
  while (n) {
    if (n % 2 == 1) result = result * x;
    n = n / 2;
    x = x * x;
  }
  return result;
}
long long int gcd(long long int a, long long int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int BS(long long int a[], long long int s, long long int n,
                 long long int val) {
  long long int mid, beg = s, end = n - 1;
  while (beg <= end) {
    mid = (beg + end) / 2;
    if (val == a[mid]) {
      break;
    } else if (val > a[mid]) {
      beg = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  return mid;
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    pair<long long int, long long int> a[20];
    for (long long int i = 0; i < k; i++) {
      cin >> a[i].second >> a[i].first;
    }
    sort(a, a + k);
    long long int sum = 0;
    for (long long int j = k - 1; j >= 0; j--) {
      sum += min(n, a[j].second) * a[j].first;
      n -= min(n, a[j].second);
    }
    cout << sum << "\n";
  }
  return 0;
}
