#include <bits/stdc++.h>
using namespace std;
int sum(int x) {
  int sum = 0;
  while (x != 0) {
    int r = x % 10;
    x /= 10;
    sum += r;
  }
  return sum;
}
int main() {
  int a;
  cin >> a;
  int temp = a;
  while (1) {
    int rs = sum(temp);
    if (rs % 4 == 0) {
      cout << temp << endl;
      break;
    }
    temp++;
  }
  return 0;
}
