def find_road_number(S): current_road = 1 increment = 1 for direction in S: if direction == 'L': current_road += increment else: # direction == 'R' current_road += increment + 1 increment = increment * 2 return current_road # input関数を使ってユーザーからの入力を受け取る S = input("分岐の方向を入力してください(例:LR): ").strip() # 結果を出力 print(find_road_number(S))