~cpp import unittest def isAllOne(aValue): valueStr = str(aValue) for each in valueStr: if each != '1': return False return True def isMultiplyOf(aValue, mulValue): return aValue % mulValue == 0 def ones(aValue): theOnes = "1" while True: onesValue = int(theOnes) if isMultiplyOf(onesValue,aValue): return len(theOnes) theOnes += "1" class OnesTest(unittest.TestCase): def testSmall(self): self.assertEquals(3, ones(3)) self.assertEquals(6, ones(7)) def testSmall2(self): self.assertEquals(9, ones(9)) def testLarge(self): self.assertEquals(12, ones(9901)) def testIsAllOne(self): self.assert_(isAllOne(1111)) self.assert_(not isAllOne(1112)) def main(): print ones(int(raw_input())) if __name__=="__main__": #unittest.main(argv=('','-v')) main()