#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  cin >> N;
  int sum = N % 10;
  for (int i = 10; i < N * 10; i *= 10) {
    sum += (N / i) % 10;
  };
  while (sum % 4 != 0) {
    N++;
    sum = N % 10;
    for (int i = 10; i < N * 10; i *= 10) {
      sum += (N / i) % 10;
    };
  }
  cout << N;
  return 0;
}
