#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, n, b, i, x = 0;
  cin >> a;
  b = a;
  while (b) {
    x += b % 10;
    b = b / 10;
  }
  if (x % 4 == 0) {
    cout << a << endl;
  } else {
    while (x % 4 != 0) {
      a++;
      b = a;
      x = 0;
      while (b) {
        x += b % 10;
        b = b / 10;
      }
      if (x % 4 == 0) {
        cout << a << endl;
        break;
      }
    }
  }
}
