#include <bits/stdc++.h>
using namespace std;
// it times out
bool f( int a,int b){
return a>b;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
vector<int> v,p;
for(int i=0;i<=1000000;i++){
int r=(i*41+78)%1997;
v.push_back(r);
p.push_back(r);
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
sort(p.begin(),p.end(),f);
int l=0;
for(int i=0;i<=1000000;i++){
if(v[i]==p[i]){
l++;
}
}
cout<<l;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Ci8vIGl0IHRpbWVzIG91dApib29sIGYoIGludCBhLGludCBiKXsKCXJldHVybiBhPmI7Cn0KaW50IG1haW4oKSB7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKCWNpbi50aWUoTlVMTCk7IGNvdXQudGllKE5VTEwpOwoJdmVjdG9yPGludD4gdixwOwoJZm9yKGludCBpPTA7aTw9MTAwMDAwMDtpKyspewoJCWludCByPShpKjQxKzc4KSUxOTk3OwoJCXYucHVzaF9iYWNrKHIpOwoJCXAucHVzaF9iYWNrKHIpOwoJfQoJc29ydCh2LmJlZ2luKCksdi5lbmQoKSk7CglyZXZlcnNlKHYuYmVnaW4oKSx2LmVuZCgpKTsKCXNvcnQocC5iZWdpbigpLHAuZW5kKCksZik7CglpbnQgbD0wOwoJZm9yKGludCBpPTA7aTw9MTAwMDAwMDtpKyspewoJCWlmKHZbaV09PXBbaV0pewoJCWwrKzsKCQl9Cgl9Cgljb3V0PDxsOwp9