#include<stdio.h>

int main(){
	//long prime=24691,root=106,x,pkey=12375;
       	long prime,root,pkey,x=0,temp=1;
	printf("\nEnter the pair (p,g)ie the Prime and root ");
	scanf("%ld%ld",&prime,&root);
	printf("\nenter the public key");
	scanf("%ld",&pkey);
	while(1){
		x++;
		temp=(temp*root)%prime;
		if(temp==pkey){
			break;
		}
	}
	printf("\nkey=%d\n",x);
	return 1;
}	
	
	
