#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int f(int x) {
  int cnt = 0;
  while (x > 0) {
    cnt += (x % 10);
    x /= 10;
  }
  return (cnt % 4 == 0);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  n--;
  while (!f(++n))
    ;
  cout << n << "\n";
}
