#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
long long check(long long x) {
  long long sum = 0;
  while (x) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  while (cin >> n) {
    while (check(n) % 4 != 0) ++n;
    cout << n << "\n";
  }
  return 0;
}
