using static System.Console;
public static void Main() {
var texto = "0001>0002>0003>0004>0005";
for (var i = 0; i < 3; i++) {
posicao = texto.IndexOf(">", posicao + 1);
if (posicao == -1) break;
if (posicao > -1) texto = texto.Substring(0, posicao);
for (var i = 0; i < 3; i++) {
posicao = texto.IndexOf(">", posicao + 1);
if (posicao == -1) break;
if (posicao > -1) texto = texto.Substring(0, posicao);