#include <bits/stdc++.h>
using namespace std;
bool judge(int n) {
  int count = 0;
  while (n > 0) {
    count += n % 10;
    n /= 10;
  }
  if (count % 4 == 0)
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  while (true) {
    if (judge(n))
      break;
    else
      n++;
  }
  cout << n;
}
