#include<iostream> using namespace std; int main() { int i=1,n,sum=0; cin>>n; while(i<=n){ if(!(i%7==0||i%10==7||i/10%10==7||i/100==7)){ sum+=i; } i++; } cout<<sum; return 0; }