#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b;
  cin >> a;
  b = a;
  int c = 0;
  do {
    a = b;
    c = 0;
    while (a > 0) {
      c += a % 10;
      a /= 10;
    }
    b++;
  } while (c % 4 != 0);
  cout << b - 1;
}
