#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  for (int i = a; i <= 1000000; i++) {
    int x = i, sum = 0;
    while (x > 0) {
      sum += x % 10;
      x /= 10;
    }
    if (sum % 4 == 0) {
      cout << i;
      break;
    }
  }
  return 0;
}
