fork(3) download
  1. # your code goes here
  2. m = int(raw_input())
  3. import os
  4. from os.path import commonprefix
  5. k1 = raw_input()
  6. k2 = raw_input()
  7. l1 = list(k1)
  8. l2 = list(k2)
  9.  
  10. lf = []
  11. ls = []
  12. for i in range(m):
  13. s = l2.pop(0)
  14. l2.append(s)
  15. ln = []
  16. ln.append(l1)
  17. ln.append(l2)
  18. lf.append(len(os.path.commonprefix(ln)))
  19.  
  20. f = max(lf)
  21. print lf.index(f)+1
  22.  
Success #stdin #stdout 0s 7856KB
stdin
5
ccadd
bddcc
stdout
3