#include <bits/stdc++.h>
using namespace std;
const double M = pow(2, 32);
const long long int modinv = 5 * (pow(10, 8)) + 4;
struct Compare {
  constexpr bool operator()(pair<int, int> const& a,
                            pair<int, int> const& b) const noexcept {
    return (a.first > b.first) || (a.first == b.first && a.second > b.second);
  }
};
int main() {
  long long int a;
  cin >> a;
  long long int sum = 0;
  do {
    sum = 0;
    long long int temp = a;
    while (temp != 0) {
      sum += temp % 10;
      temp /= 10;
    }
    a++;
  } while (sum % 4 != 0);
  cout << a - 1 << endl;
}
