#include <bits/stdc++.h>
using namespace std;
int sum_of_digits(int x) {
  int sum = 0;
  while (x) {
    sum += (x % 10);
    x /= 10;
  }
  return sum;
}
int main() {
  int a, sof = 0;
  cin >> a;
  sof = sum_of_digits(a);
  while (true) {
    if (sof % 4 == 0) {
      cout << a;
      return 0;
    }
    sof = sum_of_digits(++a);
  }
  return 0;
}
