#include <bits/stdc++.h>
using namespace std;
int a, tong = 0, t, res;
void pt(int x) {
  tong = 0;
  while (t > 0) {
    tong += t % 10;
    t /= 10;
  }
}
int main() {
  cin >> a;
  for (int i = a; i <= 1003; i++) {
    t = i;
    pt(i);
    if (tong % 4 == 0) {
      res = i;
      break;
    }
  }
  cout << res;
}
