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