#include <bits/stdc++.h>
using namespace std;
int solve(int t) {
  int a, b, c, rem = 0, sum = 0;
  while (t != 0) {
    rem = t % 10;
    sum += rem;
    t /= 10;
  }
  if (sum % 4 == 0) return 1;
  return 0;
}
int main() {
  int t, n, flag = 0;
  cin >> t;
  while (1) {
    flag = solve(t);
    if (flag == 1) {
      cout << t << "\n";
      break;
    } else
      t++;
  }
  return 0;
}
