#include <bits/stdc++.h>
using namespace std;
int n;
bool isMagic(int n) {
  int sum = 0;
  while (n > 0) {
    sum += (n % 10);
    n = n / 10;
  }
  return (sum % 4 == 0);
}
int main() {
  cin >> n;
  while (isMagic(n) == false) {
    n++;
  }
  cout << n << endl;
}
