#include <bits/stdc++.h>
using namespace std;
void init() { freopen("input.txt", "r", stdin); }
int main() {
  string input, output;
  cin >> input >> output;
  int k;
  cin >> k;
  long long int mod = 1000 * 1000 * 1000 + 7;
  int length = input.length();
  vector<long long int> previous(length), present(length);
  present[0] = 1;
  for (int i = 1; i < length; ++i) {
    present[i] = 0;
  }
  for (int i = 0; i < k; ++i) {
    previous = present;
    long long int sum = 0;
    for (int j = 0; j < length; ++j) {
      sum += previous[j];
    }
    for (int j = 0; j < length; ++j) {
      present[j] = (sum - previous[j]) % mod;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < length; ++i) {
    bool equals = true;
    for (int j = 0; j < length - i; ++j) {
      if (input[i + j] != output[j]) {
        equals = false;
      }
    }
    for (int j = length - i; j < length; ++j) {
      if (input[j - length + i] != output[j]) {
        equals = false;
      }
    }
    if (equals) {
      ans += present[i];
    }
  }
  ans = ans % mod;
  cout << ans;
  return 0;
}
