#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e7, N2 = 1e8, delta = 46639, inf = 5e7;
const long double PI = 3.141592653589793;
vector<long long int> v[N], g;
string i_s(long long int n) {
  string s = "";
  while (n) {
    s += (n % 10 + '0');
    n /= 10;
  }
  return (s);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long int n;
  cin >> n;
  while (1) {
    string s = i_s(n);
    long long int ans = 0;
    for (long long int i = 0; i < s.size(); i++) ans += (s[i] - '0');
    if (!(ans % 4)) return cout << (n), 0;
    n++;
  }
}
