can someone tell me what's wrong with my program

#include <stdio.h>
#include <string.h>
int main(void) {

	char a[100000];
int position=0,last,last1;
int jum=0;
fgets(a, 100000, stdin);
long p=strlen(a);

position=0;
while(position<p-1){
	char *result = strrchr(a, a[position]);
    last = result - a;

if(last==position){
	 result = strrchr(a, a[position-1]);
    last = result - a;
	 result = strrchr(a, a[position+1]);
    last1 = result - a;
    if(last>last1)
    position--;
    else
    position++;
	jum++;
}
else
{
	position=last;
	jum++;
}
}



printf("%d\n",jum);
	return 0;
}

you need to indent the program properly before posting it here.

//