#include <bits/stdc++.h>
using namespace std;
const int _____________________________________________________ = 0;
const int ______________________________________________________ = 1;
const int _______________________________________________________ = 2;
const int ____________________________________________ =
    ______________________________________________________ << 19;
int ______________________________
    [____________________________________________],
    ________________________________
        [____________________________________________
         << ______________________________________________________],
    _______________________________
        [____________________________________________
         << ______________________________________________________],
    _______________________ =
        ______________________________________________________,
    __________________________________________________ =
        _____________________________________________________;
int _____________________________________
    [____________________________________________],
    ___________________________________________________ =
        _____________________________________________________;
int _________________________________________________
    [_______________________________________________________] =
        {-______________________________________________________,
         -______________________________________________________},
    _______ = _____________________________________________________;
int ____________________________________
    [____________________________________________];
int ______________________________________
    [____________________________________________];
int ______________________________________________ =
    _____________________________________________________;
void _______________________________________(int ___________, int _____________,
                                             int __________________) {
  ____________________________________[___________] =
      ______________________________________________________;
  _____________________________________[___________] =
      __________________
          ? ______________________________________________________
          : -______________________________________________________;
  for (int ___ = _____________________________________________________;
       ___ < _______________________________________________________; ___++)
    if (_________________________________________________[___] == ___________)
      _____________________________________[___________] += _______,
          ______________________________________[___________] +=
          ______________________________________________________ -
          _______________________________________________________ * ___;
  for (int _____ = ______________________________[___________]; _____;
       _____ = _______________________________[_____]) {
    int _________ = ________________________________[_____];
    if (_________ == _____________ ||
        (_____ >> ______________________________________________________) ==
            __________________________________________________)
      continue;
    if ((!___________________________________________________) &&
        ____________________________________[_________]) {
      __________________________________________________ =
          _____ >> ______________________________________________________;
      ___________________________________________________ =
          ______________________________________________________;
      _________________________________________________
      [_____________________________________________________] = ___________,
      _________________________________________________
          [______________________________________________________] = _________;
      continue;
    }
    _______________________________________(
        _________, ___________,
        __________________ ^
            ______________________________________________________);
    _____________________________________[___________] +=
        _____________________________________[_________];
    ______________________________________[___________] +=
        ______________________________________[_________];
  }
  for (int ___ = _____________________________________________________;
       ___ < _______________________________________________________; ___++)
    if (_________________________________________________[___] == ___________)
      ______________________________________________ ^= __________________;
}
void _____________________________________________(int ___________,
                                                   int _________) {
  ________________________________[++_______________________] = _________;
  _______________________________[_______________________] =
      ______________________________[___________];
  ______________________________[___________] = _______________________;
}
int _________________________________, __________________________________;
long long _________________________________________(
    long long _______________________________________________) {
  return _______________________________________________ >
                 _____________________________________________________
             ? _______________________________________________
             : -_______________________________________________;
}
void ________________________________________________(
    long long ___________________________________) {
  for (int ___ = ______________________________________________________;
       ___ <= _________________________________; ___++)
    ___________________________________ +=
        _________________________________________(
            _____________________________________[___]);
  cout << ___________________________________;
  exit(_____________________________________________________);
}
int __________________________[____________________________________________];
int main() {
  scanf("%d%d", &_________________________________,
        &__________________________________);
  for (int ___ = ______________________________________________________,
           ___________, _________;
       ___ <= __________________________________; ___++)
    scanf("%d%d", &___________, &_________),
        _____________________________________________(___________, _________),
        _____________________________________________(_________, ___________);
  _______________________________________(
      ______________________________________________________,
      _____________________________________________________,
      ______________________________________________________);
  if (__________________________________ < _________________________________) {
    if (_____________________________________
            [______________________________________________________])
      return _____________________________________________________ &
             puts("-______________________________________________________");
    ________________________________________________(
        _____________________________________________________);
  }
  if (!______________________________________________) {
    if (_____________________________________
                [______________________________________________________] %
            _______________________________________________________ !=
        _____________________________________________________)
      return _____________________________________________________ &
             puts("-______________________________________________________");
    _______ = -_____________________________________
                  [______________________________________________________] /
              _______________________________________________________;
    _______________________________________(
        ______________________________________________________,
        _____________________________________________________,
        ______________________________________________________);
    ________________________________________________(
        _________________________________________(_______));
  }
  if (_____________________________________
          [______________________________________________________])
    return _____________________________________________________ &
           puts("-______________________________________________________");
  _______________________________________(
      ______________________________________________________,
      _____________________________________________________,
      ______________________________________________________);
  int tp = ______________________________________________________;
  long long ___________________________________ =
      _____________________________________________________;
  __________________________
  [______________________________________________________] =
      _____________________________________________________;
  for (int ___ = ______________________________________________________;
       ___ <= _________________________________; ___++)
    if (______________________________________[___])
      __________________________[++tp] =
          ______________________________________[___] >
                  _____________________________________________________
              ? -_____________________________________[___]
              : _____________________________________[___];
  nth_element(
      __________________________ +
          ______________________________________________________,
      __________________________ +
          ((tp + ______________________________________________________) >>
           ______________________________________________________),
      __________________________ + tp +
          ______________________________________________________);
  int ________________________________________ = __________________________
      [(tp + ______________________________________________________) >>
       ______________________________________________________];
  for (int ___ = ______________________________________________________;
       ___ <= _________________________________; ___++)
    ___________________________________ +=
        _________________________________________(
            ______________________________________[___] *
                ________________________________________ +
            _____________________________________[___]);
  cout << ___________________________________ +
              _________________________________________(
                  ________________________________________);
  return _____________________________________________________;
}
