#include <bits/stdc++.h>
using namespace std;
int givesum(int n) {
  int cnt = 0;
  while (n) {
    cnt += n % 10;
    n /= 10;
  }
  return cnt;
}
int main() {
  int a;
  cin >> a;
  while (givesum(a) % 4 != 0) {
    a++;
  }
  cout << a << endl;
}
