#include <bits/stdc++.h>
using namespace std;
int n, m;
long long ans;
pair<int, int> arr[25];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) scanf("%d%d", &arr[i].second, &arr[i].first);
  sort(arr, arr + m);
  reverse(arr, arr + m);
  for (int i = 0; i < m && n; ++i)
    if (arr[i].second < n)
      ans += arr[i].first * arr[i].second, n -= arr[i].second;
    else
      ans += arr[i].first * n, n = 0;
  printf("%lld\n", ans);
  return 0;
}
