#include "_.h"

typedef struct structure {
    long nbr;
    struct structure *next;
} struc;

int main(int argc, char **argv) {
	
	if (argc != 2)
		return 1;

	char *input = argv[1];
	char **inputs = str_split(strdup(input), ' ');
    struc *head = calloc(1, sizeof(struc));
    struc *cur = head;

	for (int i = 0; inputs[i] != NULL; i++) {
        cur->nbr = atol(inputs[i]);
        cur->next = calloc(1, sizeof(struc));
        cur = cur->next;
    }

    for (int i = 0; i < 25; i++) {
        cur = head;
        for (int j = 0; cur->next != NULL; j++) {
            if (cur->nbr == 0) {
                cur->nbr = 1;
                cur = cur->next;
            }
            else if (((long)floor(log10(ABS(cur->nbr))) + 1) % 2 == 0) {
                double len = floor(log10(ABS(cur->nbr))) + 1;
                long left = cur->nbr / (pow(10, len / 2)); 
                long right = cur->nbr % (long)(pow(10, len / 2)); 

                struc *new = calloc(1, sizeof(struc));
                new->nbr = right;
                new->next = cur->next;

                cur->nbr = left;
                cur->next = new;
                cur = new->next;
            }
            else {
                cur->nbr *= 2024;
                cur = cur->next;
            }
        }
    }

    long count = 0;
    cur = head;
    while (cur->next != NULL) {
        cur = cur->next;
        count++;
    }
    printf("count: %ld\n", count);
    

	return 0;
}
