SP3868 MTOTALF - Total Flow

Description

[English](/problems/MTOTALF/en/) [Vietnamese](/problems/MTOTALF/vn/) ``` Farmer John always wants his cows to have enough water and thus has made a map of the N (1

Input Format

``` * Line 1: A single integer: N * Lines 2..N + 1: Line i+1 describes pipe i with two letters and an integer, all space-separated: a_i, b_i, and F_i SAMPLE INPUT 5 A B 3 B C 3 C D 5 D Z 4 B Z 6 ```

Output Format

``` * Line 1: A single integer that the maximum flow from the well ('A') to the barn ('Z') SAMPLE OUTPUT 3 ```