#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
using namespace std;
void solve() {
  int a;
  cin >> a;
  for (int n = a;; ++n) {
    int sum = 0;
    int x = n;
    while (x) {
      sum += x % 10;
      x /= 10;
    }
    if (sum % 4 == 0) {
      cout << n << "\n";
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
