#include <bits/stdc++.h>
using namespace std;
int n, s, c;
int main() {
  cin >> n;
  s = n;
  c = 0;
  while (s > 0) {
    c += s % 10;
    s /= 10;
  }
  while (c % 4 != 0) {
    n++;
    s = n;
    c = 0;
    while (s > 0) {
      c += s % 10;
      s /= 10;
    }
  }
  cout << n;
}
