#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  while (1) {
    int cnt = 0;
    int temp = a;
    while (temp) {
      cnt += (temp % 10);
      temp /= 10;
    }
    if (cnt % 4 == 0) break;
    a++;
  }
  cout << a;
  return 0;
}
