#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long s = 0;
  long long m;
  do {
    m = n;
    s = 0;
    while (m > 0) {
      s += m % 10;
      m /= 10;
    }
    n++;
  } while (s % 4 != 0);
  cout << n - 1;
  return 0;
}
