#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  int a, b, c, d;
  cin >> n;
  int m = n;
  while (1) {
    a = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    d = n % 10;
    n /= 10;
    if ((a + b + c + d) % 4 == 0) break;
    m++;
    n = m;
  }
  printf("%d\n", m);
  return 0;
}
