#include <iostream>
using namespace std;
int n, sum = 0;
int a[4] = {1, 4, 16, 64};
int main()
{
cin >> n;
n = 1024 - n;
for(int i = 3; i >= 0; i--)
{
sum += n / a[i];
n %= a[i];
}
cout << sum << endl;
return 0;
}