找字串 运行错误 怎么解决?

找子串个数,提交oj平台总是说运行错误,可是自己编译没问题啊,qiu'jie

#include<iostream>
#include<algorithm>
#include<string>


using namespace std;
int main()
{
    int j = 0, cnt = 0;
    string s1, s2;
    getline(cin,s1);
    while (getline(cin,s2))
    {
        for (unsigned int i = 0; i < s2.length() - s1.length() + 1;)
        {
            if (s2[i] == s1[j])
            {
                unsigned int k, count = 0;
                for (k = 0; k < s1.length() && s2[i] == s1[j]; i++, k++, j++)
                {
                    count++;
                }
                if (count == s1.length())
                {
                    cnt++;
                }count = 0; j = 0;
            }
            else 
                i++;
        }
    }
    cout << cnt;
    return 0;
}