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