#!/usr/bin/env python3 import sys steps = next(sys.stdin).split(", ") x = 0 y = 0 for step in steps: if step[0] == "R": x, y = -y, x else: x, y = y, -x x += int(step[1:]) print(abs(x) + abs(y))