void main(){import std.range,std.stdio;stdin.byLine.tee!(l=>write(l[1]==l[2]?l[2]:l[4])).walkLength;}