#include <bits/stdc++.h>
using namespace std;
int find(int num) {
  stringstream ss;
  string str;
  int sum = 0;
  ss << num;
  ss >> str;
  for (int a = 0; str[a] != '\0'; a++) {
    sum += (str[a] - 48);
  }
  if (sum % 4 == 0) {
    return num;
  } else {
    return find(++num);
  }
}
int main() {
  int num;
  cin >> num;
  cout << find(num);
}
