Display post X of Y in category

Okay, this should do, what you want:

// Fetch all posts in the current post's (main) category
$args = array(
    'post_type' => 'post',
    'posts_per_page' => -1,
    'cat' => array_shift(get_the_category())->cat_ID,
);
$query = new WP_Query($args);

// The index of the current post in its (main) category
$X = 1;
$id = get_the_ID();
foreach ($query->posts as $cat_post)
    if ($id != $cat_post->ID)
        $X++;
    else
        break;

// The number of posts in the current post's (main) category
$Y = $query->found_posts;

// Now, display what we got...
echo $X."https://wordpress.stackexchange.com/".$Y;

What is happening?
We fetch all posts of the current (main) category, ordered by Published date. That way, we already have the total number of posts in that category. Then we iterate through the posts and increment a counter variable to track the index of the current post. Finally, we display these numbers somewhere.