I don't know how long to run the loop for : I'm working on this small code. It is giving the right output but I think the loop that I have on it could be improved.

Question 1: Given a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1.

Example:
A = ‘abcd’
B = ‘cdabcdab’
The function should return 3 because after stating A 3 times, getting ‘abcdabcdabcd’, B is now a substring of A.

You can assume that n and m are integers in the range [1, 1000].

This is my code: 

    #include "pch.h"
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <istream>

    using namespace std;
    int findthestring(string A, string B)
    {
	string original = B;
	int x;
	int times = 1 ;
	for (unsigned int i = 0; i < (10 * A.length());i++)
	{
	
		if (B.find(A) != string::npos)
		{
			x = 1;
			cout << "String Found\n";
		}
		else
		{
			x = 0;
			cout << "String not Found\n";
			B = B + original;
			times = times + 1;
		}
		
	}
     return times;
	
      }
       main()
      {
	     int times = findthestring("cdabcdab","abcd");
	     cout << "Number of Times: " << times;

      }

On this code, I have the loop running for 3 times the length of A because I assumed if it runs for that long and a substring is not found, then I'm never going to find one. How can that be improved ? 