#include<bits/stdc++.h>
using namespace std;
bool fun(int x)
{
int t=0;
while(x)
{
t+=x%10;
x/=10;
}
return t%4==0;
}
int main()
{
int n;
cin>>n;
for(int i=n;;i++)
{
if(fun(i))
{
cout<<i<<endl;
return 0;
}
}
}