p=0 for i in range(100,1000): s=0 for j in [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,51]: if i%j!=0: s+=1 if s==16: p+=1 print(p)