#include <iostream>
int main()
{
int n,n1,k,k1;
std::cout << "n = ";
std::cin >> n;
std::cout << "k = ";
std::cin >> k;
n1 = n;
k1 = 1;
while ((n1 /= 10) > 0) k1++;
while (k1-- != k) n1 /= 10;
k1 = n1%10;
while ((n1 /= 10) > 0) k1 += n1 % 10;
std::cout << "Result = " << k1;
return 0;
}
#include <iostream>
int main()
{
int n,n1,k,k1;
std::cout << "n = ";
std::cin >> n;
std::cout << "k = ";
std::cin >> k;
n1 = n;
k1 = 1;
while ((n1 /= 10) > 0) k1++;
n1 = n;
while (k1-- != k) n1 /= 10;
k1 = n1%10;
while ((n1 /= 10) > 0) k1 += n1 % 10;
std::cout << "Result = " << k1;
return 0;
}