#include <bits/stdc++.h>
using namespace std;
bool summ(int n) {
  int k, sum = 0;
  while (n != 0) {
    k = n % 10;
    sum += k;
    n /= 10;
  }
  if (sum % 4 == 0)
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  for (int i = n;; i++) {
    if (summ(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
