#include <bits/stdc++.h>
using namespace std;
const int maxx = 500 + 7;
const int maxn = (1E5) * 2 + 7;
const long long mod = 1E9 + 7;
const int maxs = 3 * (1E7) + 5;
const int maxm = 100 + 3;
int getsum(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}
int a, n;
void solve() {
  cin >> a;
  n = a;
  while (1) {
    int tt = getsum(n);
    if (tt % 4 == 0) break;
    n++;
  }
  cout << n << endl;
}
int main(void) {
  solve();
  return 0;
}
