#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, e, b, cnt, a;
int arr[N];
int onedigit(int n) {
  cnt = 0;
  while (n) {
    cnt += (n % 10);
    n /= 10;
  }
  return cnt;
}
int main() {
  cin >> a;
al:
  e = onedigit(a);
  if (e % 4) {
    a++;
    goto al;
  }
  cout << a;
}
