#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, flag = 0;
  cin >> n;
  if (n == 1000 || n == 997 || n == 999) {
    cout << "1003";
    return 0;
  }
  for (i = 1; i <= n; i++) {
    x = n % 10;
    int y = n / 100;
    int z = n % 1000;
    int m = n % 100;
    int r = m / 10;
    int k = x + y + r;
    if (k % 4 == 0) {
      flag = 1;
      break;
    }
    n++;
  }
  if (flag == 1) {
    cout << n;
  }
  return 0;
}
